Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2014-07-23 10:28:28 -0400
committerUwe Stieber2014-07-23 10:28:48 -0400
commit9e97c888255f5d7a2436c1e5469ae708833a48f7 (patch)
treea72cea46b1de0c35ed76f9bbb5373b930649f7e7
parent6b8c5066b38813e1a6279771730a61bc456381b3 (diff)
downloadorg.eclipse.tcf-9e97c888255f5d7a2436c1e5469ae708833a48f7.tar.gz
org.eclipse.tcf-9e97c888255f5d7a2436c1e5469ae708833a48f7.tar.xz
org.eclipse.tcf-9e97c888255f5d7a2436c1e5469ae708833a48f7.zip
Target Explorer: Fix channel communication logging
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/META-INF/MANIFEST.MF2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/schema/listeners.exsd34
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/Tcf.java87
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java83
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/ChannelManager.java19
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/ChannelListener.java101
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/ChannelOpenListener.java68
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/interfaces/IChannelOpenListener.java29
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/interfaces/IChannelStateChangeListener.java27
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/nls/Messages.properties6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/plugin.xml40
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java45
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/Startup.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelStateChangeListener.java37
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java32
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java57
17 files changed, 199 insertions, 512 deletions
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 d9663ff07..ffa24ff74 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
@@ -23,6 +23,7 @@ Export-Package: org.eclipse.tcf.te.tcf.core,
org.eclipse.tcf.te.tcf.core.async,
org.eclipse.tcf.te.tcf.core.channelmanager,
org.eclipse.tcf.te.tcf.core.concurrent,
+ org.eclipse.tcf.te.tcf.core.events,
org.eclipse.tcf.te.tcf.core.help,
org.eclipse.tcf.te.tcf.core.interfaces,
org.eclipse.tcf.te.tcf.core.interfaces.steps,
@@ -35,7 +36,6 @@ Export-Package: org.eclipse.tcf.te.tcf.core,
org.eclipse.tcf.te.tcf.core.internal.utils;x-internal:=true,
org.eclipse.tcf.te.tcf.core.iterators,
org.eclipse.tcf.te.tcf.core.jobs,
- org.eclipse.tcf.te.tcf.core.listeners,
org.eclipse.tcf.te.tcf.core.listeners.interfaces,
org.eclipse.tcf.te.tcf.core.nls;x-internal:=true,
org.eclipse.tcf.te.tcf.core.peers,
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/schema/listeners.exsd b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/schema/listeners.exsd
index 3f21bda2d..28043a8d6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/schema/listeners.exsd
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/schema/listeners.exsd
@@ -6,7 +6,7 @@
<meta.schema plugin="org.eclipse.tcf.te.tcf.core" id="listeners" name="Listeners"/>
</appinfo>
<documentation>
- This extension point is used to contribute TCF protocol state change and TCF channel state change listeners.
+ This extension point is used to contribute TCF protocol state change listeners.
</documentation>
</annotation>
@@ -19,7 +19,6 @@
<complexType>
<choice>
<element ref="protocolStateChangeListener" minOccurs="1" maxOccurs="unbounded"/>
- <element ref="channelStateChangeListener" minOccurs="1" maxOccurs="unbounded"/>
</choice>
<attribute name="point" type="string" use="required">
<annotation>
@@ -75,33 +74,6 @@
</complexType>
</element>
- <element name="channelStateChangeListener">
- <annotation>
- <documentation>
- Declares a TCF channel state change listener contribution.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- The unique id of the TCF channel state change listener contribution.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The class that implements &lt;code&gt;org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener&lt;/code&gt;.
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
<annotation>
<appinfo>
<meta.section type="since"/>
@@ -134,7 +106,7 @@
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
- Depending on the type of the contributed listener, the provider of a listener must either implement &lt;samp&gt;org.eclipse.tcf.te.tcf.core.listeners.interfaces.IProtocolStateChangeListener&lt;/samp&gt; or &lt;samp&gt;org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener&lt;/samp&gt;.
+ The provider of a protocol state change listener must implement &lt;samp&gt;org.eclipse.tcf.te.tcf.core.listeners.interfaces.IProtocolStateChangeListener&lt;/samp&gt;.
</documentation>
</annotation>
@@ -144,7 +116,7 @@
<meta.section type="copyright"/>
</appinfo>
<documentation>
- Copyright (c) 2012 Wind River Systems, Inc. and others.
+ Copyright (c) 2012 - 2104 Wind River Systems, Inc. and others.
All rights reserved.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/Tcf.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/Tcf.java
index 79186e64b..e4bfbadc0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/Tcf.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/Tcf.java
@@ -23,15 +23,11 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.protocol.Protocol.ChannelOpenListener;
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.internal.Startup;
import org.eclipse.tcf.te.tcf.core.internal.channelmanager.ChannelManager;
-import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelOpenListener;
-import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener;
import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IProtocolStateChangeListener;
import org.eclipse.tcf.te.tcf.core.nls.Messages;
@@ -42,10 +38,7 @@ import org.eclipse.tcf.te.tcf.core.nls.Messages;
public final class Tcf {
/* default */ IChannelManager channelManager;
- /* default */ ChannelOpenListener channelOpenListener;
-
/* default */ final List<IProtocolStateChangeListener> protocolStateChangeListeners = new ArrayList<IProtocolStateChangeListener>();
- /* default */ final List<IChannelStateChangeListener> channelStateChangeListeners = new ArrayList<IChannelStateChangeListener>();
/*
@@ -120,59 +113,6 @@ public final class Tcf {
}
/**
- * Adds a listener that will be notified once the TCF framework state changes.
- *
- * @param listener The listener. Must not be <code>null</code>.
- */
- public static final void addChannelStateChangeListener(IChannelStateChangeListener listener) {
- Assert.isTrue(Protocol.isDispatchThread());
- Assert.isNotNull(listener);
-
- Tcf tcf = getInstance();
- Assert.isNotNull(tcf);
-
- if (!tcf.channelStateChangeListeners.contains(listener)) {
- tcf.channelStateChangeListeners.add(listener);
- }
- }
-
- /**
- * Removes the specified protocol state change listener.
- *
- * @param listener The listener. Must not be <code>null</code>.
- */
- public static final void removeChannelStateChangeListener(IChannelStateChangeListener listener) {
- Assert.isTrue(Protocol.isDispatchThread());
- Assert.isNotNull(listener);
-
- Tcf tcf = getInstance();
- Assert.isNotNull(tcf);
-
- tcf.channelStateChangeListeners.remove(listener);
- }
-
- /**
- * Fires the channel state change listeners.
- *
- * @param channel The channel which changed state. Must not be <code>null</code>.
- * @param state The new state.
- */
- public static final void fireChannelStateChangeListeners(final IChannel channel, final int state) {
- Assert.isTrue(Protocol.isDispatchThread());
- Assert.isNotNull(channel);
-
- Tcf tcf = getInstance();
- Assert.isNotNull(tcf);
-
- final IChannelStateChangeListener[] listeners = tcf.channelStateChangeListeners.toArray(new IChannelStateChangeListener[tcf.channelStateChangeListeners.size()]);
- if (listeners.length > 0) {
- for (IChannelStateChangeListener listener : listeners) {
- listener.stateChanged(channel, state);
- }
- }
- }
-
- /**
* Returns if or if not the TCF framework is up and running.
*
* @return <code>True</code> if the framework is up and running, <code>false</code> otherwise.
@@ -195,12 +135,6 @@ public final class Tcf {
Tcf tcf = getInstance();
Assert.isNotNull(tcf);
- // Create and register the global channel open listener
- if (tcf.channelOpenListener == null) {
- tcf.channelOpenListener = new org.eclipse.tcf.te.tcf.core.listeners.ChannelOpenListener();
- Protocol.addChannelOpenListener(tcf.channelOpenListener);
- }
-
// Create and register listeners contributed via extension point
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint point = registry.getExtensionPoint("org.eclipse.tcf.te.tcf.core.listeners"); //$NON-NLS-1$
@@ -221,18 +155,6 @@ public final class Tcf {
Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
}
}
- else if ("channelStateChangeListener".equals(element.getName())) { //$NON-NLS-1$
- try {
- // Create the channel state change listener instance
- IChannelStateChangeListener listener = (IChannelStateChangeListener)element.createExecutableExtension("class"); //$NON-NLS-1$
- if (listener != null) addChannelStateChangeListener(listener);
- } catch (CoreException e) {
- IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(),
- NLS.bind(Messages.Extension_error_invalidChannelStateChangeListener, element.getDeclaringExtension().getUniqueIdentifier()),
- e);
- Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status);
- }
- }
}
}
}
@@ -265,12 +187,6 @@ public final class Tcf {
Tcf tcf = getInstance();
Assert.isNotNull(tcf);
- // Unregister the channel open listener of created
- if (tcf.channelOpenListener != null) {
- Protocol.removeChannelOpenListener(tcf.channelOpenListener);
- tcf.channelOpenListener = null;
- }
-
// Signal to interested listeners that we've just went down
final IProtocolStateChangeListener[] listeners = tcf.protocolStateChangeListeners.toArray(new IProtocolStateChangeListener[tcf.protocolStateChangeListeners.size()]);
if (listeners.length > 0) {
@@ -334,9 +250,6 @@ public final class Tcf {
if (IChannelManager.class.equals(adapter)) {
return tcf.channelManager;
}
- if (IChannelOpenListener.class.equals(adapter)) {
- return tcf.channelOpenListener;
- }
return Platform.getAdapterManager().getAdapter(tcf, adapter);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java
new file mode 100644
index 000000000..4929d1c46
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * 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.events;
+
+import java.util.EventObject;
+
+import org.eclipse.tcf.protocol.IChannel;
+
+/**
+ * Channel event implementation.
+ */
+public final class ChannelEvent extends EventObject {
+ private static final long serialVersionUID = 864759021559875199L;
+
+ public static final String TYPE_OPEN = "open"; //$NON-NLS-1$
+ public static final String TYPE_REDIRECT = "redirect"; //$NON-NLS-1$
+ public static final String TYPE_CLOSE = "close"; //$NON-NLS-1$
+
+ // The channel
+ private IChannel channel;
+ // The event type
+ private String type;
+ // The optional message
+ private String message;
+
+ /**
+ * Constructor
+ *
+ * @param source The source object. Must not be <code>null</code>.
+ * @param channel The channel. Must not be <code>null</code>.
+ * @param type The event type. Must not be <code>null</code>.
+ * @param message A message or <code>null</code>.
+ */
+ public ChannelEvent(Object source, IChannel channel, String type, String message) {
+ super(source);
+
+ if (channel == null) {
+ throw new IllegalArgumentException("null channel"); //$NON-NLS-1$
+ }
+
+ if (type == null) {
+ throw new IllegalArgumentException("null type"); //$NON-NLS-1$
+ }
+
+ this.channel = channel;
+ this.type = type;
+ this.message = message;
+ }
+
+ /**
+ * Returns the channel.
+ *
+ * @return The channel.
+ */
+ public IChannel getChannel() {
+ return channel;
+ }
+
+ /**
+ * Returns the event type.
+ *
+ * @return The event type.
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Returns the optional message.
+ *
+ * @return The optional message or <code>null</code>.
+ */
+ public String getMessage() {
+ return message;
+ }
+}
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 857bc2ec8..bdb8ded07 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
@@ -27,6 +27,7 @@ import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.IStreams;
import org.eclipse.tcf.te.runtime.callback.Callback;
+import org.eclipse.tcf.te.runtime.events.EventManager;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
@@ -36,6 +37,7 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService;
import org.eclipse.tcf.te.runtime.stepper.job.StepperJob;
import org.eclipse.tcf.te.runtime.stepper.utils.StepperHelper;
import org.eclipse.tcf.te.tcf.core.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.tcf.core.events.ChannelEvent;
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;
@@ -93,6 +95,7 @@ public class ChannelManager extends PlatformObject implements IChannelManager {
@Override
public void doneOpenChannel(final Throwable error, final IChannel channel) {
+ // Invoke the client done callback
Runnable runnable = new Runnable() {
@Override
public void run() {
@@ -119,8 +122,8 @@ public class ChannelManager extends PlatformObject implements IChannelManager {
// First thing to determine is if to open a new channel or the shared
// channel can be used, if there is a shared channel at all.
boolean forceNew = flags != null && flags.containsKey(IChannelManager.FLAG_FORCE_NEW) ? flags.get(IChannelManager.FLAG_FORCE_NEW).booleanValue() : false;
- boolean noValueAdd = flags != null && flags.containsKey(IChannelManager.FLAG_NO_VALUE_ADD) ? flags.get(IChannelManager.FLAG_NO_VALUE_ADD).booleanValue() : false;
- boolean noPathMap = flags != null && flags.containsKey(IChannelManager.FLAG_NO_PATH_MAP) ? flags.get(IChannelManager.FLAG_NO_PATH_MAP).booleanValue() : false;
+ final boolean noValueAdd = flags != null && flags.containsKey(IChannelManager.FLAG_NO_VALUE_ADD) ? flags.get(IChannelManager.FLAG_NO_VALUE_ADD).booleanValue() : false;
+ final boolean noPathMap = flags != null && flags.containsKey(IChannelManager.FLAG_NO_PATH_MAP) ? flags.get(IChannelManager.FLAG_NO_PATH_MAP).booleanValue() : false;
// If noValueAdd == true or noPathMap == true -> forceNew has to be true as well
if (noValueAdd || noPathMap) forceNew = true;
@@ -239,6 +242,14 @@ public class ChannelManager extends PlatformObject implements IChannelManager {
0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager.this);
}
+ // Log successfully opened channels
+ String message = finForceNew ? "Private" : "Shared"; //$NON-NLS-1$ //$NON-NLS-2$
+ if (noValueAdd) message += ", No Value Add"; //$NON-NLS-1$
+ if (noPathMap) message += ", Not Applying Path Map"; //$NON-NLS-1$
+
+ ChannelEvent event = new ChannelEvent(ChannelManager.this, channel, ChannelEvent.TYPE_OPEN, message);
+ EventManager.getInstance().fireEvent(event);
+
// Invoke the primary "open channel" done callback
internalDone.doneOpenChannel(null, channel);
@@ -459,6 +470,10 @@ public class ChannelManager extends PlatformObject implements IChannelManager {
0, ITraceIds.TRACE_CHANNEL_MANAGER, IStatus.INFO, ChannelManager.this);
}
}
+
+ // Log closed channels
+ ChannelEvent event = new ChannelEvent(ChannelManager.this, channel, ChannelEvent.TYPE_CLOSE, null);
+ EventManager.getInstance().fireEvent(event);
}
};
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/ChannelListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/ChannelListener.java
deleted file mode 100644
index 191f5257a..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/ChannelListener.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * 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.listeners;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.core.interfaces.tracing.ITraceIds;
-import org.eclipse.tcf.te.tcf.core.internal.utils.LogUtils;
-import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelOpenListener;
-import org.eclipse.tcf.te.tcf.core.nls.Messages;
-
-
-/**
- * Channel listener implementation.
- */
-public class ChannelListener implements IChannel.IChannelListener {
- // The reference to the channel
- private final IChannel channel;
-
- /**
- * Constructor.
- *
- * @param channel The channel. Must not be <code>null</code>.
- */
- public ChannelListener(IChannel channel) {
- Assert.isNotNull(channel);
- this.channel = channel;
- }
-
- /**
- * Return the associated channel.
- *
- * @return The channel instance.
- */
- protected final IChannel getChannel() {
- return channel;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.protocol.IChannel.IChannelListener#congestionLevel(int)
- */
- @Override
- public void congestionLevel(int level) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.protocol.IChannel.IChannelListener#onChannelClosed(java.lang.Throwable)
- */
- @Override
- public void onChannelClosed(Throwable error) {
- Assert.isTrue(Protocol.isDispatchThread());
-
- // Detach the listeners cleanly
- detachListeners(getChannel());
-
- // Construct the cause message
- String cause = ""; //$NON-NLS-1$
- if (error != null) {
- cause = NLS.bind(Messages.InternalChannelListener_onChannelClosed_cause, error.getLocalizedMessage());
- }
-
- // Trace the channel closing
- LogUtils.logMessageForChannel(getChannel(), NLS.bind(Messages.InternalChannelListener_onChannelClosed_message, cause), ITraceIds.TRACE_CHANNELS, this);
-
- // Fire the property change event for the channel
- Tcf.fireChannelStateChangeListeners(getChannel(), IChannel.STATE_CLOSED);
- }
-
- /**
- * Detach all registered listeners from the given channel.
- *
- * @param channel The channel. Must not be <code>null</code>.
- */
- protected void detachListeners(IChannel channel) {
- Assert.isNotNull(channel);
-
- // Cleanly remove all listeners from the channel
- channel.removeChannelListener(this);
-
- // And remove the listener references from the global channel open listener
- IChannelOpenListener openListener = (IChannelOpenListener)Tcf.getAdapter(IChannelOpenListener.class);
- if (openListener != null) openListener.setChannelListener(channel, null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.protocol.IChannel.IChannelListener#onChannelOpened()
- */
- @Override
- public void onChannelOpened() {
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/ChannelOpenListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/ChannelOpenListener.java
deleted file mode 100644
index 774f8a681..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/ChannelOpenListener.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * 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.listeners;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.IChannel.IChannelListener;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.core.interfaces.tracing.ITraceIds;
-import org.eclipse.tcf.te.tcf.core.internal.utils.LogUtils;
-import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelOpenListener;
-import org.eclipse.tcf.te.tcf.core.nls.Messages;
-
-
-/**
- * Channel open listener implementation.
- */
-public class ChannelOpenListener implements IChannelOpenListener {
- // Static map containing the channel listeners per channel. Access to the
- // map should happen from the TCF protocol dispatch thread only.
- private final Map<IChannel, IChannel.IChannelListener> channelListeners = new HashMap<IChannel, IChannel.IChannelListener>();
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.protocol.Protocol.ChannelOpenListener#onChannelOpen(org.eclipse.tcf.protocol.IChannel)
- */
- @Override
- public void onChannelOpen(IChannel channel) {
- Assert.isNotNull(channel);
- Assert.isTrue(Protocol.isDispatchThread());
-
- // Trace the channel opening
- LogUtils.logMessageForChannel(channel, Messages.InternalChannelOpenListener_onChannelOpen_message, ITraceIds.TRACE_CHANNELS, this);
-
- // As the channel has just opened, there should be no channel listener, but better be safe and check.
- IChannel.IChannelListener channelListener = channelListeners.remove(channel);
- if (channelListener != null) channel.removeChannelListener(channelListener);
- // Create a new channel listener instance
- channelListener = new ChannelListener(channel);
- // Add the channel listener to the global map
- setChannelListener(channel, channelListener);
- // Attach channel listener to the channel
- channel.addChannelListener(channelListener);
-
- // Fire the property change event for the channel
- Tcf.fireChannelStateChangeListeners(channel, IChannel.STATE_OPEN);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.core.internal.interfaces.IChannelOpenListener#setChannelListener(org.eclipse.tcf.protocol.IChannel, org.eclipse.tcf.protocol.IChannel.IChannelListener)
- */
- @Override
- public void setChannelListener(IChannel channel, IChannelListener listener) {
- Assert.isNotNull(channel);
- if (listener != null) channelListeners.put(channel, listener);
- else channelListeners.remove(channel);
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/interfaces/IChannelOpenListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/interfaces/IChannelOpenListener.java
deleted file mode 100644
index 2b194b59f..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/interfaces/IChannelOpenListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * 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.listeners.interfaces;
-
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.protocol.Protocol.ChannelOpenListener;
-
-/**
- * Enhanced channel open listener interface for internal use.
- */
-public interface IChannelOpenListener extends ChannelOpenListener {
-
- /**
- * Stores the given channel listener to the internal map. The map
- * key is the given channel. If the given channel listener is <code>null</code>,
- * the channel is removed from the internal map.
- *
- * @param channel The channel. Must not be <code>null</code>.
- * @param listener The channel listener or <code>null</code>.
- */
- public void setChannelListener(IChannel channel, IChannel.IChannelListener listener);
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/interfaces/IChannelStateChangeListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/interfaces/IChannelStateChangeListener.java
deleted file mode 100644
index 45f755fac..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/listeners/interfaces/IChannelStateChangeListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * 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.listeners.interfaces;
-
-import org.eclipse.tcf.protocol.IChannel;
-
-/**
- * Interface for clients to implement that wishes to listen
- * channel state changes, like opening and closing of a channel.
- */
-public interface IChannelStateChangeListener {
-
- /**
- * Invoked if the channel state has changed.
- *
- * @param channel The channel which changed state.
- * @param state The new state.
- */
- public void stateChanged(IChannel channel, int state);
-}
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 944917288..dfa60644d 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
@@ -67,11 +67,6 @@ public class Messages extends NLS {
// **** Declare externalized string id's down here *****
- public static String InternalChannelOpenListener_onChannelOpen_message;
-
- public static String InternalChannelListener_onChannelClosed_message;
- public static String InternalChannelListener_onChannelClosed_cause;
-
public static String ChannelManager_openChannel_message;
public static String ChannelManager_openChannel_reuse_message;
public static String ChannelManager_openChannel_pending_message;
@@ -108,7 +103,6 @@ public class Messages extends NLS {
public static String MonitorTask_TimeoutError;
public static String Extension_error_invalidProtocolStateChangeListener;
- public static String Extension_error_invalidChannelStateChangeListener;
public static String AbstractJob_error_dialogTitle;
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 f84c606c2..9571a5281 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,11 +8,6 @@
# Wind River Systems - initial API and implementation
###############################################################################
-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. Target id = {0}, flags = {1}
ChannelManager_openChannel_reuse_message=Reusing already opened channel. Target id = {0}, new reference count = {1}
ChannelManager_openChannel_pending_message=Opening channel in progress. Callback ({1}) marked pending. Target id = {0}
@@ -49,7 +44,6 @@ CallbackMonitor_AllTasksFinished=All tasks are finished\!
MonitorTask_TimeoutError=The callback monitor has timed out\!
Extension_error_invalidProtocolStateChangeListener=Failed to instantiate the protocol state change listener from extension point ''{0}''.
-Extension_error_invalidChannelStateChangeListener=Failed to instantiate the channel state change listener from extension point ''{0}''.
AbstractJob_error_dialogTitle=Error
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/plugin.xml
index 9745df43c..ecbc6f4b1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/plugin.xml
@@ -1,17 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-
-<!-- TCF framework startup participant -->
- <extension point="org.eclipse.tcf.startup">
- <class name="org.eclipse.tcf.te.tcf.log.core.internal.Startup"/>
- </extension>
-
-<!-- Preference contributions -->
- <extension point="org.eclipse.core.runtime.preferences">
- <initializer
- class="org.eclipse.tcf.te.tcf.log.core.internal.PreferencesInitializer">
- </initializer>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+<!-- Preference contributions -->
+ <extension point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.tcf.te.tcf.log.core.internal.PreferencesInitializer">
+ </initializer>
+ </extension>
+
+<!-- Event listener contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.eventListeners">
+ <eventListener
+ class="org.eclipse.tcf.te.tcf.log.core.internal.listener.EventListener"
+ forcePluginActivation="true">
+ <eventType
+ bundleId="org.eclipse.tcf.te.tcf.core"
+ class="org.eclipse.tcf.te.tcf.core.events.ChannelEvent">
+ </eventType>
+ </eventListener>
+ </extension>
+</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java
index 7b44f3388..77f332df1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/LogManager.java
@@ -27,28 +27,21 @@ import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.events.EventManager;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener;
-import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IProtocolStateChangeListener;
import org.eclipse.tcf.te.tcf.log.core.activator.CoreBundleActivator;
import org.eclipse.tcf.te.tcf.log.core.events.MonitorEvent;
import org.eclipse.tcf.te.tcf.log.core.interfaces.IPreferenceKeys;
-import org.eclipse.tcf.te.tcf.log.core.internal.listener.ChannelStateChangeListener;
import org.eclipse.tcf.te.tcf.log.core.internal.nls.Messages;
/**
* TCF logging log manager implementation.
*/
-public final class LogManager implements IProtocolStateChangeListener {
+public final class LogManager {
/**
* Time format representing date and time with milliseconds.
*/
public final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); //$NON-NLS-1$
- // Reference to the channel state change listener
- private IChannelStateChangeListener channelStateChangeListener;
-
// Maps file writer per log file base name
private final Map<String, FileWriter> fileWriterMap = new HashMap<String, FileWriter>();
@@ -141,42 +134,6 @@ public final class LogManager implements IProtocolStateChangeListener {
}
/**
- * Create, register and initialize the listeners.
- * <p>
- * <b>Note:</b> This method is supposed to be called from {@link Startup} only!
- */
- /* default */ final void initListeners() {
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
-
- // If the channel state change listener instance has been created
- // already, there is nothing left to do here
- if (channelStateChangeListener != null) return;
-
- // Register ourself as protocol change listener
- Tcf.addProtocolStateChangeListener(this);
-
- // Create and register the channel state change listener
- channelStateChangeListener = new ChannelStateChangeListener();
- Tcf.addChannelStateChangeListener(channelStateChangeListener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.core.listeners.interfaces.IProtocolStateChangeListener#stateChanged(boolean)
- */
- @Override
- public void stateChanged(boolean state) {
- Assert.isTrue(Protocol.isDispatchThread());
-
- // On shutdown, get the listener removed and disposed
- if (!state) {
- Tcf.removeChannelStateChangeListener(channelStateChangeListener);
- channelStateChangeListener = null;
-
- Tcf.removeProtocolStateChangeListener(this);
- }
- }
-
- /**
* Returns the file writer instance to use for the given channel.
*
* @param channel The channel. Must not be <code>null</code>.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/Startup.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/Startup.java
deleted file mode 100644
index 152f1f829..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/Startup.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * 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.log.core.internal;
-
-import org.eclipse.tcf.protocol.Protocol;
-
-
-/**
- * Class loaded by the TCF core framework when the framework is fired up. The static
- * constructor of the class will trigger the registration of the listeners in order
- * to log the communication from the point the framework started up.
- * <p>
- * <b>Note:</b> This will effectively trigger {@link CoreBundleActivator#start(org.osgi.framework.BundleContext)}
- * to be called.
- */
-public class Startup {
-
- static {
- // We might get here on shutdown as well, and if TCF has not
- // been loaded, than we will run into an NPE. Lets double check.
- if (Protocol.getEventQueue() != null) {
- // Execute the listener registration within the TCF dispatch thread
- Protocol.invokeLater(new Runnable() {
- @Override
- public void run() {
- LogManager.getInstance().initListeners();
- }
- });
- }
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelStateChangeListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelStateChangeListener.java
deleted file mode 100644
index 9903a8994..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelStateChangeListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * 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.log.core.internal.listener;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener;
-
-/**
- * TCF logging channel state listener implementation.
- */
-public class ChannelStateChangeListener implements IChannelStateChangeListener {
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener#stateChanged(org.eclipse.tcf.protocol.IChannel, int)
- */
- @Override
- public void stateChanged(IChannel channel, int state) {
- Assert.isNotNull(channel);
-
- switch(state) {
- case IChannel.STATE_OPEN:
- ChannelTraceListenerManager.getInstance().onChannelOpened(channel);
- break;
- case IChannel.STATE_CLOSED:
- ChannelTraceListenerManager.getInstance().onChannelClosed(channel);
- break;
- }
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java
index bbe812574..2158bae63 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java
@@ -65,10 +65,11 @@ public class ChannelTraceListenerManager {
* New channel opened. Attach a channel trace listener.
*
* @param channel The channel. Must not be <code>null</code>.
+ * @param message A message or <code>null</code>.
*/
- public void onChannelOpened(final IChannel channel) {
+ public void onChannelOpened(final IChannel channel, String message) {
Assert.isNotNull(channel);
- Assert.isTrue(Protocol.isDispatchThread());
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
// The trace listener interface does not have a onChannelOpenend method, but
// for consistency, log the channel opening similar to the others.
@@ -80,15 +81,10 @@ public class ChannelTraceListenerManager {
// The trace listeners can be accessed only via AbstractChannel
if (!(channel instanceof AbstractChannel)) return;
- // If the locator events shall be logged, we need to log the communication
- // to the value-adds as well.
- boolean locatorEvents = CoreBundleActivator.getScopedPreferences().getBoolean(IPreferenceKeys.PREF_SHOW_LOCATOR_EVENTS);
-
- // If the channel is opened to a ValueAdd, do not write a log file (except
- // if the locator communication logging is enabled).
+ // If the channel is opened to a ValueAdd, do not write a log file.
String value = channel.getRemotePeer().getAttributes().get("ValueAdd"); //$NON-NLS-1$
boolean isValueAdd = value != null && ("1".equals(value.trim()) || Boolean.parseBoolean(value.trim())); //$NON-NLS-1$
- if (isValueAdd && !locatorEvents) return;
+ if (isValueAdd) return;
// Get the preference key if or if not logging is enabled
boolean loggingEnabled = CoreBundleActivator.getScopedPreferences().getBoolean(IPreferenceKeys.PREF_LOGGING_ENABLED);
@@ -108,26 +104,26 @@ public class ChannelTraceListenerManager {
// Log the channel opening
String date = DATE_FORMAT.format(new Date(System.currentTimeMillis()));
- String message = NLS.bind(Messages.ChannelTraceListener_channelOpened_message,
- new Object[] {
- date,
- Integer.toHexString(channel.hashCode()),
- isValueAdd ? "[" + channel.getRemotePeer().getID() + "]" : "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- });
+ String fullMessage = NLS.bind(Messages.ChannelTraceListener_channelOpened_message,
+ new Object[] {
+ date,
+ Integer.toHexString(channel.hashCode()),
+ message != null ? "(" + message.trim() + ")" : "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ });
// Get the file writer
FileWriter writer = LogManager.getInstance().getWriter(channel);
if (writer != null) {
try {
writer.write("\n\n\n"); //$NON-NLS-1$
- writer.write(message);
+ writer.write(fullMessage);
writer.write("\n"); //$NON-NLS-1$
writer.flush();
} catch (IOException e) {
/* ignored on purpose */
}
}
- LogManager.getInstance().monitor(channel, MonitorEvent.Type.OPEN, new MonitorEvent.Message('F', message));
+ LogManager.getInstance().monitor(channel, MonitorEvent.Type.OPEN, new MonitorEvent.Message('F', fullMessage));
}
/**
@@ -137,7 +133,7 @@ public class ChannelTraceListenerManager {
*/
public void onChannelClosed(final IChannel channel) {
Assert.isNotNull(channel);
- Assert.isTrue(Protocol.isDispatchThread());
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
// The trace listeners can be accessed only via AbstractChannel
if (!(channel instanceof AbstractChannel)) return;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java
new file mode 100644
index 000000000..dde27f425
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.log.core.internal.listener;
+
+import java.util.EventObject;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.interfaces.events.IEventFireDelegate;
+import org.eclipse.tcf.te.runtime.interfaces.events.IEventListener;
+import org.eclipse.tcf.te.tcf.core.events.ChannelEvent;
+
+/**
+ * Channel event listener.
+ */
+public final class EventListener extends PlatformObject implements IEventListener, IEventFireDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.events.IEventFireDelegate#fire(java.lang.Runnable)
+ */
+ @Override
+ public void fire(Runnable runnable) {
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeLater(runnable);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject)
+ */
+ @Override
+ public void eventFired(EventObject event) {
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ if (event instanceof ChannelEvent) {
+ final IChannel channel = ((ChannelEvent)event).getChannel();
+ final String type = ((ChannelEvent)event).getType();
+ final String message = ((ChannelEvent)event).getMessage();
+
+ if (ChannelEvent.TYPE_OPEN.equals(type)) {
+ ChannelTraceListenerManager.getInstance().onChannelOpened(channel, message);
+ }
+ else if (ChannelEvent.TYPE_CLOSE.equals(type)) {
+ ChannelTraceListenerManager.getInstance().onChannelClosed(channel);
+ }
+ }
+ }
+
+}

Back to the top