null
.
- */
- 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 null
.
- */
- 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 null
.
- * @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.
*
@@ -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 null
.
+ * @param channel The channel. Must not be null
.
+ * @param type The event type. Must not be null
.
+ * @param message A message or null
.
+ */
+ 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 null
.
+ */
+ 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 null
.
- */
- 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 null
.
- */
- 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 Mapnull
,
- * the channel is removed from the internal map.
- *
- * @param channel The channel. Must not be null
.
- * @param listener The channel listener or null
.
- */
- 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 @@
-
-
-- * Note: 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. * 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. - *
- * Note: 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 null
.
+ * @param message A message or null
.
*/
- 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);
+ }
+ }
+ }
+
+}
--
cgit v1.2.3