Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2009-04-28 21:24:26 +0000
committereutarass2009-04-28 21:24:26 +0000
commitf16758ec430c29a988bd2c3c406e67928b6de04a (patch)
tree326d56e05a59d69ce0782545ddef820f768d0a57 /plugins/org.eclipse.tm.tcf
parent3fd5065d866497172fff9c2f69553a165df4e550 (diff)
downloadorg.eclipse.tcf-f16758ec430c29a988bd2c3c406e67928b6de04a.tar.gz
org.eclipse.tcf-f16758ec430c29a988bd2c3c406e67928b6de04a.tar.xz
org.eclipse.tcf-f16758ec430c29a988bd2c3c406e67928b6de04a.zip
Bug 273078:[tcf][api] Separate TCF Core from TCF Eclipse Integration
Diffstat (limited to 'plugins/org.eclipse.tm.tcf')
-rw-r--r--plugins/org.eclipse.tm.tcf/.classpath1
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/ChannelLoop.java91
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/LocalPeer.java32
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/RemotePeer.java35
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/ServiceManager.java84
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/Token.java75
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/TransportManager.java179
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/local/ChannelProxy.java154
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/local/DiagnosticsService.java157
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java739
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/BreakpointsProxy.java234
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/DiagnosticsProxy.java220
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ExpressionsProxy.java267
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/FileSystemProxy.java596
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/GenericProxy.java39
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/LineNumbersProxy.java80
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/LocatorProxy.java235
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/MemoryProxy.java409
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ProcessesProxy.java315
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RegistersProxy.java390
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RunControlProxy.java258
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/StackTraceProxy.java129
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/StreamsProxy.java152
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/SymbolsProxy.java162
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/SysMonitorProxy.java200
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/AbstractChannel.java953
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/AbstractPeer.java186
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/Base64.java148
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/ChannelTCP.java103
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/Command.java232
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/ErrorReport.java66
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/ServerTCP.java147
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/StreamChannel.java81
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IChannel.java299
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IErrorReport.java99
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IEventQueue.java49
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/ILogger.java28
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IPeer.java74
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IService.java30
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IServiceProvider.java22
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IToken.java32
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/ITransportProvider.java37
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/JSON.java613
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/Protocol.java412
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IBreakpoints.java322
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IDiagnostics.java245
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IExpressions.java333
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IFileSystem.java664
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ILineNumbers.java166
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ILocator.java125
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IMemory.java302
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IProcesses.java320
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRegisters.java437
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRunControl.java331
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IStackTrace.java150
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IStreams.java191
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ISymbols.java209
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ISysMonitor.java379
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFDataCache.java211
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFFileInputStream.java252
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFFileOutputStream.java158
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFTask.java323
62 files changed, 1 insertions, 13961 deletions
diff --git a/plugins/org.eclipse.tm.tcf/.classpath b/plugins/org.eclipse.tm.tcf/.classpath
index 304e86186..0182778c5 100644
--- a/plugins/org.eclipse.tm.tcf/.classpath
+++ b/plugins/org.eclipse.tm.tcf/.classpath
@@ -3,5 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/org.eclipse.tm.tcf.core"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/ChannelLoop.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/ChannelLoop.java
deleted file mode 100644
index b27eba05b..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/ChannelLoop.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.core;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-
-import org.eclipse.tm.tcf.core.StreamChannel;
-import org.eclipse.tm.tcf.protocol.IPeer;
-
-
-public class ChannelLoop extends StreamChannel {
-
- private final byte[] buf = new byte[0x1000];
- private int buf_inp;
- private int buf_out;
- private boolean waiting;
- private boolean closed;
-
- ChannelLoop(IPeer peer) {
- super(peer);
- start();
- }
-
- @Override
- protected synchronized int get() throws IOException {
- try {
- while (buf_inp == buf_out) {
- if (closed) return -1;
- waiting = true;
- wait();
- }
- int b = buf[buf_out] & 0xff;
- buf_out = (buf_out + 1) % buf.length;
- if (waiting) {
- waiting = false;
- notifyAll();
- }
- return b;
- }
- catch (InterruptedException e) {
- throw new InterruptedIOException();
- }
- }
-
- @Override
- protected synchronized void put(int b) throws IOException {
- assert b >=0 && b <= 0xff;
- try {
- for (;;) {
- int nxt_inp = (buf_inp + 1) % buf.length;
- if (nxt_inp != buf_out) {
- buf[buf_inp] = (byte)b;
- buf_inp = nxt_inp;
- break;
- }
- if (closed) return;
- waiting = true;
- wait();
- }
- if (waiting) {
- waiting = false;
- notifyAll();
- }
- }
- catch (InterruptedException e) {
- throw new InterruptedIOException();
- }
- }
-
- @Override
- protected void flush() throws IOException {
- }
-
- @Override
- protected synchronized void stop() throws IOException {
- closed = true;
- if (waiting) {
- waiting = false;
- notifyAll();
- }
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/LocalPeer.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/LocalPeer.java
deleted file mode 100644
index 11a29fed3..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/LocalPeer.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.core;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.AbstractPeer;
-
-public class LocalPeer extends AbstractPeer {
-
- private static Map<String,String> createAttributes() {
- Map<String, String> attrs = new HashMap<String, String>();
- attrs.put(ATTR_ID, "TCFLocal");
- attrs.put(ATTR_NAME, "Local Peer");
- attrs.put(ATTR_OS_NAME, System.getProperty("os.name"));
- attrs.put(ATTR_TRANSPORT_NAME, "Loop");
- return attrs;
- }
-
- public LocalPeer() {
- super(createAttributes());
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/RemotePeer.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/RemotePeer.java
deleted file mode 100644
index 5facfa264..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/RemotePeer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.core;
-
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.AbstractPeer;
-
-public class RemotePeer extends AbstractPeer {
-
- private long last_update_time;
-
- public RemotePeer(Map<String,String> attrs) {
- super(attrs);
- last_update_time = System.currentTimeMillis();
- }
-
- @Override
- public void updateAttributes(Map<String,String> attrs) {
- super.updateAttributes(attrs);
- last_update_time = System.currentTimeMillis();
- }
-
- public long getLastUpdateTime() {
- return last_update_time;
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/ServiceManager.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/ServiceManager.java
deleted file mode 100644
index 8389e355e..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/ServiceManager.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Anyware Technologies 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:
- * Anyware Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.tcf.core;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-
-import org.eclipse.tm.internal.tcf.services.local.DiagnosticsService;
-import org.eclipse.tm.internal.tcf.services.remote.GenericProxy;
-import org.eclipse.tm.internal.tcf.services.remote.LocatorProxy;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IServiceProvider;
-
-public class ServiceManager {
-
- private static final Collection<IServiceProvider> providers = new ArrayList<IServiceProvider>();
-
- static {
- addServiceProvider(new IServiceProvider() {
-
- private final String package_name = LocatorProxy.class.getPackage().getName();
-
- public IService[] getLocalService(IChannel channel) {
- return new IService[]{ new DiagnosticsService(channel) };
- }
-
- public IService getServiceProxy(IChannel channel, String service_name) {
- IService service = null;
- try {
- Class<?> cls = Class.forName(package_name + "." + service_name + "Proxy");
- service = (IService)cls.getConstructor(IChannel.class).newInstance(channel);
- assert service_name.equals(service.getName());
- }
- catch (Exception x) {
- }
- return service;
- }
- });
-
- }
-
- public static void addServiceProvider(IServiceProvider provider) {
- providers.add(provider);
- }
-
- public static void removeServiceProvider(IServiceProvider provider) {
- providers.remove(provider);
- }
-
- public static void onChannelCreated(IChannel channel, Map<String,IService> services) {
- for (IServiceProvider provider : providers) {
- IService[] arr = provider.getLocalService(channel);
- if (arr == null) continue;
- for (IService service : arr) {
- if (services.containsKey(service.getName())) continue;
- services.put(service.getName(), service);
- }
- }
- }
-
- public static void onChannelOpened(IChannel channel, Collection<String> service_names, Map<String,IService> services) {
- for (String name : service_names) {
- for (IServiceProvider provider : providers) {
- IService service = provider.getServiceProxy(channel, name);
- if (service == null) continue;
- services.put(name, service);
- break;
- }
- if (!services.containsKey(name)) {
- services.put(name, new GenericProxy(channel, name));
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/Token.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/Token.java
deleted file mode 100644
index 2e2f4c101..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/Token.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.core;
-
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-
-public class Token implements IToken {
-
- private static int cnt = 0;
-
- private final String id;
- private final byte[] bytes;
- private final IChannel.ICommandListener listener;
-
- public Token() {
- id = null;
- bytes = null;
- listener = null;
- }
-
- public Token(IChannel.ICommandListener listener) {
- this.listener = listener;
- id = Integer.toString(cnt++);
- try {
- bytes = id.getBytes("ASCII");
- }
- catch (UnsupportedEncodingException e) {
- throw new Error(e);
- }
- }
-
- public Token(byte[] bytes) {
- this.bytes = bytes;
- listener = null;
- try {
- id = new String(bytes, "ASCII");
- }
- catch (UnsupportedEncodingException e) {
- throw new Error(e);
- }
- }
-
- public boolean cancel() {
- return false;
- }
-
- public String getID() {
- return id;
- }
-
- public byte[] getBytes() {
- return bytes;
- }
-
- public IChannel.ICommandListener getListener() {
- return listener;
- }
-
- @Override
- public String toString() {
- return id;
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/TransportManager.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/TransportManager.java
deleted file mode 100644
index 2e6e214d8..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/core/TransportManager.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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.tm.internal.tcf.core;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.tm.tcf.core.AbstractChannel;
-import org.eclipse.tm.tcf.core.AbstractPeer;
-import org.eclipse.tm.tcf.core.ChannelTCP;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IPeer;
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.ITransportProvider;
-import org.eclipse.tm.tcf.protocol.Protocol;
-import org.eclipse.tm.tcf.services.ILocator;
-
-
-public class TransportManager {
-
- private static final Collection<AbstractChannel> channels =
- new LinkedList<AbstractChannel>();
- private static final Collection<Protocol.ChannelOpenListener> listeners =
- new LinkedList<Protocol.ChannelOpenListener>();
- private static final HashMap<String,ITransportProvider> transports =
- new HashMap<String,ITransportProvider>();
-
- static {
- addTransportProvider(new ITransportProvider() {
-
- public String getName() {
- return "TCP";
- }
-
- public IChannel openChannel(IPeer peer) {
- assert getName().equals(peer.getTransportName());
- Map<String,String> attrs = peer.getAttributes();
- String host = attrs.get(IPeer.ATTR_IP_HOST);
- String port = attrs.get(IPeer.ATTR_IP_PORT);
- if (host == null) throw new Error("No host name");
- if (port == null) throw new Error("No port number");
- return new ChannelTCP(peer, host, Integer.parseInt(port));
- }
- });
-
- addTransportProvider(new ITransportProvider() {
-
- public String getName() {
- return "Loop";
- }
-
- public IChannel openChannel(IPeer peer) {
- assert getName().equals(peer.getTransportName());
- return new ChannelLoop(peer);
- }
- });
- }
-
- public static void addTransportProvider(ITransportProvider transport) {
- String name = transport.getName();
- assert name != null;
- if (transports.get(name) != null) throw new Error("Already registered: " + name);
- transports.put(name, transport);
- }
-
- public static void removeTransportProvider(ITransportProvider transport) {
- String name = transport.getName();
- assert name != null;
- if (transports.get(name) == transport) transports.remove(name);
- }
-
- public static IChannel openChannel(IPeer peer) {
- String name = peer.getTransportName();
- if (name == null) throw new Error("No transport name");
- ITransportProvider transport = transports.get(name);
- if (transport == null) throw new Error("Unknown transport name: " + name);
- return transport.openChannel(peer);
- }
-
- public static void channelOpened(final AbstractChannel channel) {
- assert !channels.contains(channel);
- channels.add(channel);
- for (Protocol.ChannelOpenListener l : listeners) {
- try {
- l.onChannelOpen(channel);
- }
- catch (Throwable x) {
- Protocol.log("Exception in channel listener", x);
- }
- }
- }
-
- public static void channelClosed(final AbstractChannel channel, final Throwable x) {
- assert channels.contains(channel);
- channels.remove(channel);
- }
-
- public static IChannel[] getOpenChannels() {
- return channels.toArray(new IChannel[channels.size()]);
- }
-
- public static void addChanelOpenListener(Protocol.ChannelOpenListener listener) {
- listeners.add(listener);
- }
-
- public static void removeChanelOpenListener(Protocol.ChannelOpenListener listener) {
- listeners.remove(listener);
- }
-
- public static void peerDisposed(AbstractPeer peer) {
- Exception error = null;
- Collection<AbstractChannel> bf = new ArrayList<AbstractChannel>(channels);
- for (Iterator<AbstractChannel> i = bf.iterator(); i.hasNext();) {
- AbstractChannel c = i.next();
- if (c.getRemotePeer() != peer) continue;
- if (error == null) error = new Exception("Peer is disposed");
- c.terminate(error);
- }
- }
-
- /**
- * Transmit TCF event message.
- * The message is sent to all open communication channels – broadcasted.
- *
- * This is internal API, TCF clients should use {@code org.eclipse.tm.tcf.protocol.Protocol}.
- */
- public static void sendEvent(String service_name, String event_name, byte[] data) {
- for (Iterator<AbstractChannel> i = channels.iterator(); i.hasNext();) {
- AbstractChannel channel = i.next();
- IService s = channel.getLocalService(service_name);
- if (s != null) channel.sendEvent(s, event_name, data);
- }
- }
-
- /**
- * Call back after TCF messages sent by this host up to this moment are delivered
- * to their intended targets. This method is intended for synchronization of messages
- * across multiple channels.
- *
- * Note: Cross channel synchronization can reduce performance and throughput.
- * Most clients don't need cross channel synchronization and should not call this method.
- *
- * @param done will be executed by dispatch thread after communication
- * messages are delivered to corresponding targets.
- *
- * This is internal API, TCF clients should use {@code org.eclipse.tm.tcf.protocol.Protocol}.
- */
- public static void sync(final Runnable done) {
- final Set<IToken> set = new HashSet<IToken>();
- ILocator.DoneSync done_sync = new ILocator.DoneSync() {
- public void doneSync(IToken token) {
- assert set.contains(token);
- set.remove(token);
- if (set.isEmpty()) done.run();
- }
- };
- for (Iterator<AbstractChannel> i = channels.iterator(); i.hasNext();) {
- AbstractChannel channel = i.next();
- ILocator s = channel.getRemoteService(ILocator.class);
- if (s != null) set.add(s.sync(done_sync));
- }
- if (set.isEmpty()) Protocol.invokeLater(done);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/local/ChannelProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/local/ChannelProxy.java
deleted file mode 100644
index f3530cd38..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/local/ChannelProxy.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.tm.internal.tcf.services.local;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.tm.internal.tcf.core.ChannelLoop;
-import org.eclipse.tm.tcf.core.AbstractChannel;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-/**
- * ChannelProxy implements forwarding of TCF messages between two channels.
- * The class is used to implement Locator service "redirect" command.
- */
-class ChannelProxy {
-
- private final AbstractChannel ch_x;
- private final AbstractChannel ch_y;
-
- private boolean closed_x;
- private boolean closed_y;
-
- private final Map<IToken,IToken> tokens_x = new HashMap<IToken,IToken>();
- private final Map<IToken,IToken> tokens_y = new HashMap<IToken,IToken>();
-
- private final AbstractChannel.Proxy proxy_x = new AbstractChannel.Proxy() {
-
- public void onChannelClosed(Throwable error) {
- closed_x = true;
- if (closed_y) return;
- if (error == null) ch_y.close();
- else ch_y.terminate(error);
- }
-
- public void onCommand(IToken token, String service, String name, byte[] data) {
- if (closed_y) return;
- assert ch_y.getState() == IChannel.STATE_OPEN;
- IService s = ch_y.getRemoteService(service);
- if (s == null) ch_x.terminate(new IOException("Invalid service name"));
- else tokens_x.put(ch_y.sendCommand(s, name, data, cmd_listener_x), token);
- }
-
- public void onEvent(String service, String name, byte[] data) {
- IService s = ch_x.getRemoteService(service);
- if (s == null) ch_x.terminate(new IOException("Invalid service name"));
- else if (!closed_y) ch_y.sendEvent(s, name, data);
- }
- };
-
- private final AbstractChannel.Proxy proxy_y = new AbstractChannel.Proxy() {
-
- public void onChannelClosed(Throwable error) {
- closed_y = true;
- if (closed_x) return;
- if (error == null) ch_x.close();
- else ch_x.terminate(error);
- }
-
- public void onCommand(IToken token, String service, String name, byte[] data) {
- if (closed_x) return;
- assert ch_x.getState() == IChannel.STATE_OPEN;
- IService s = ch_x.getRemoteService(service);
- if (s == null) ch_y.terminate(new IOException("Invalid service name"));
- else tokens_y.put(ch_x.sendCommand(s, name, data, cmd_listener_y), token);
- }
-
- public void onEvent(String service, String name, byte[] data) {
- IService s = ch_y.getRemoteService(service);
- if (s == null) ch_y.terminate(new IOException("Invalid service name"));
- else if (!closed_x) ch_x.sendEvent(s, name, data);
- }
- };
-
- private final IChannel.ICommandListener cmd_listener_x = new IChannel.ICommandListener() {
-
- public void progress(IToken token, byte[] data) {
- ch_x.sendProgress(tokens_x.get(token), data);
- }
-
- public void result(IToken token, byte[] data) {
- ch_x.sendResult(tokens_x.get(token), data);
- tokens_x.remove(token);
- }
-
- public void terminated(IToken token, Exception error) {
- tokens_x.remove(token);
- }
- };
-
- private final IChannel.ICommandListener cmd_listener_y = new IChannel.ICommandListener() {
-
- public void progress(IToken token, byte[] data) {
- ch_y.sendProgress(tokens_y.get(token), data);
- }
-
- public void result(IToken token, byte[] data) {
- ch_y.sendResult(tokens_y.get(token), data);
- tokens_y.remove(token);
- }
-
- public void terminated(IToken token, Exception error) {
- tokens_y.remove(token);
- }
- };
-
- ChannelProxy(IChannel x, IChannel y) {
- assert !(x instanceof ChannelLoop);
- assert !(y instanceof ChannelLoop);
- ch_x = (AbstractChannel)x;
- ch_y = (AbstractChannel)y;
- assert ch_x.getState() == IChannel.STATE_OPEN;
- assert ch_y.getState() == IChannel.STATE_OPENNING;
- try {
- ch_y.setProxy(proxy_y, ch_x.getRemoteServices());
- ch_y.addChannelListener(new IChannel.IChannelListener() {
-
- public void congestionLevel(int level) {
- }
-
- public void onChannelClosed(Throwable error) {
- ch_y.removeChannelListener(this);
- if (error == null) error = new Exception("Channel closed");
- }
-
- public void onChannelOpened() {
- ch_y.removeChannelListener(this);
- try {
- ch_x.setProxy(proxy_x, ch_y.getRemoteServices());
- }
- catch (IOException e) {
- ch_x.terminate(e);
- ch_y.terminate(e);
- }
- }
- });
- }
- catch (IOException e) {
- ch_x.terminate(e);
- ch_y.terminate(e);
- }
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/local/DiagnosticsService.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/local/DiagnosticsService.java
deleted file mode 100644
index 76f4dcc94..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/local/DiagnosticsService.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.local;
-
-import java.math.BigDecimal;
-
-import org.eclipse.tm.internal.tcf.core.Token;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.protocol.Protocol;
-import org.eclipse.tm.tcf.services.IDiagnostics;
-
-
-public class DiagnosticsService implements IDiagnostics {
-
- private final IChannel channel;
-
- private class CommandServer implements IChannel.ICommandServer {
-
- public void command(IToken token, String name, byte[] data) {
- try {
- command(token, name, JSON.parseSequence(data));
- }
- catch (Throwable x) {
- channel.terminate(x);
- }
- }
-
- private void command(IToken token, String name, Object[] args) throws Exception {
- if (name.equals("echo")) {
- if (args.length != 1) throw new Exception("Invalid number of arguments");
- String s = (String)args[0];
- channel.sendResult(token, JSON.toJSONSequence(new Object[]{ s }));
- }
- else if (name.equals("echoFP")) {
- if (args.length != 1) throw new Exception("Invalid number of arguments");
- Number n = (Number)args[0];
- channel.sendResult(token, JSON.toJSONSequence(new Object[]{ n }));
- }
- else if (name.equals("getTestList")) {
- if (args.length != 0) throw new Exception("Invalid number of arguments");
- channel.sendResult(token, JSON.toJSONSequence(new Object[]{ null, new String[0] }));
- }
- else {
- channel.rejectCommand(token);
- }
- }
- }
-
- public DiagnosticsService(IChannel channel) {
- this.channel = channel;
- channel.addCommandServer(this, new CommandServer());
- }
-
- public String getName() {
- return NAME;
- }
-
- public IToken echo(final String s, final DoneEcho done) {
- final IToken token = new Token();
- Protocol.invokeLater(new Runnable() {
- public void run() {
- done.doneEcho(token, null, s);
- }
- });
- return token;
- }
-
- public IToken echoFP(final BigDecimal n, final DoneEchoFP done) {
- final IToken token = new Token();
- Protocol.invokeLater(new Runnable() {
- public void run() {
- done.doneEchoFP(token, null, n);
- }
- });
- return token;
- }
-
- public IToken getTestList(final DoneGetTestList done) {
- final IToken token = new Token();
- Protocol.invokeLater(new Runnable() {
- public void run() {
- done.doneGetTestList(token, null, new String[0]);
- }
- });
- return token;
- }
-
- public IToken runTest(final String s, final DoneRunTest done) {
- final IToken token = new Token();
- Protocol.invokeLater(new Runnable() {
- public void run() {
- done.doneRunTest(token, new Exception("Test suite not found: " + s), null);
- }
- });
- return token;
- }
-
- public IToken cancelTest(String context_id, final DoneCancelTest done) {
- final IToken token = new Token();
- Protocol.invokeLater(new Runnable() {
- public void run() {
- done.doneCancelTest(token, null);
- }
- });
- return token;
- }
-
- public IToken getSymbol(String context_id, String symbol_name, final DoneGetSymbol done) {
- final IToken token = new Token();
- Protocol.invokeLater(new Runnable() {
- public void run() {
- done.doneGetSymbol(token, new Exception("Invalid context"), null);
- }
- });
- return token;
- }
-
- public IToken createTestStreams(int inp_buf_size, int out_buf_size, final DoneCreateTestStreams done) {
- final IToken token = new Token();
- Protocol.invokeLater(new Runnable() {
- public void run() {
- done.doneCreateTestStreams(token, new Exception("Not implemented"), null, null);
- }
- });
- return token;
- }
-
- public IToken disposeTestStream(String id, final DoneDisposeTestStream done) {
- final IToken token = new Token();
- Protocol.invokeLater(new Runnable() {
- public void run() {
- done.doneDisposeTestStream(token, new Exception("Invalid context"));
- }
- });
- return token;
- }
-
- public IToken not_implemented_command(final DoneNotImplementedCommand done) {
- final IToken token = new Token();
- Protocol.invokeLater(new Runnable() {
- public void run() {
- done.doneNotImplementedCommand(token, new Exception("Not implemented"));
- }
- });
- return token;
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java
deleted file mode 100644
index 47e08bbca..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/local/LocatorService.java
+++ /dev/null
@@ -1,739 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.local;
-
-import java.lang.reflect.Method;
-import java.net.BindException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.tm.internal.tcf.core.LocalPeer;
-import org.eclipse.tm.internal.tcf.core.RemotePeer;
-import org.eclipse.tm.internal.tcf.core.ServiceManager;
-import org.eclipse.tm.internal.tcf.core.TransportManager;
-import org.eclipse.tm.tcf.core.AbstractChannel;
-import org.eclipse.tm.tcf.core.AbstractPeer;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IErrorReport;
-import org.eclipse.tm.tcf.protocol.IPeer;
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IServiceProvider;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.protocol.Protocol;
-import org.eclipse.tm.tcf.services.ILocator;
-
-
-/**
- * Locator service uses transport layer to search
- * for peers and to collect and maintain up-to-date
- * data about peer’s attributes.
- */
-// TODO: research usage of DNS-SD (DNS Service Discovery) to discover TCF peers
-public class LocatorService implements ILocator {
-
- private static final int DISCOVEY_PORT = 1534;
- private static final int MAX_PACKET_SIZE = 9000 - 40 - 8;
- private static final int PREF_PACKET_SIZE = 1500 - 40 - 8;
-
- private static LocatorService locator;
- private static final Map<String,IPeer> peers = new HashMap<String,IPeer>();
- private static final ArrayList<LocatorListener> listeners = new ArrayList<LocatorListener>();
-
- private final HashSet<SubNet> subnets = new HashSet<SubNet>();
- private final ArrayList<Slave> slaves = new ArrayList<Slave>();
- private final byte[] inp_buf = new byte[MAX_PACKET_SIZE];
- private final byte[] out_buf = new byte[MAX_PACKET_SIZE];
-
- private static class SubNet {
- final int prefix_length;
- final InetAddress address;
- final InetAddress broadcast;
-
- long last_slaves_req_time;
- boolean beacon_ok;
-
- SubNet(int prefix_length, InetAddress address, InetAddress broadcast) {
- this.prefix_length = prefix_length;
- this.address = address;
- this.broadcast = broadcast;
- }
-
- boolean contains(InetAddress addr) {
- if (addr == null) return false;
- byte[] a1 = addr.getAddress();
- byte[] a2 = broadcast.getAddress();
- int i = 0;
- while (i + 8 <= prefix_length) {
- int n = i / 8;
- if (a1[n] != a2[n]) return false;
- i += 8;
- }
- while (i < prefix_length) {
- int n = i / 8;
- int m = 1 << (7 - i % 8);
- if ((a1[n] & m) != (a2[n] & m)) return false;
- i++;
- }
- return true;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof SubNet)) return false;
- SubNet x = (SubNet)o;
- return
- prefix_length == x.prefix_length &&
- broadcast.equals(x.broadcast) &&
- address.equals(x.address);
- }
-
- @Override
- public int hashCode() {
- return broadcast.hashCode();
- }
-
- @Override
- public String toString() {
- return broadcast.getHostAddress() + "/" + prefix_length;
- }
- }
-
- private static class Slave {
- final InetAddress address;
- final int port;
-
- long last_packet_time;
- long last_req_slaves_time;
-
- Slave(InetAddress address, int port) {
- this.address = address;
- this.port = port;
- }
-
- @Override
- public String toString() {
- return address.getHostAddress() + ":" + port;
- }
- }
-
- private static LocalPeer local_peer;
-
- private DatagramSocket socket;
- private long last_master_packet_time;
-
- private Thread timer_thread = new Thread() {
- public void run() {
- while (true) {
- try {
- Protocol.invokeAndWait(new Runnable() {
- public void run() {
- refresh_timer();
- }
- });
- sleep(DATA_RETENTION_PERIOD / 4);
- }
- catch (IllegalStateException x) {
- // TCF event dispatch is shut down
- return;
- }
- catch (Throwable x) {
- Protocol.log("Unhandled exception in TCF discovery listening thread", x);
- }
- }
- }
- };
-
- private Thread input_thread = new Thread() {
- public void run() {
- for (;;) {
- DatagramSocket socket = LocatorService.this.socket;
- try {
- final DatagramPacket p = new DatagramPacket(inp_buf, inp_buf.length);
- socket.receive(p);
- Protocol.invokeAndWait(new Runnable() {
- public void run() {
- handleDatagramPacket(p);
- }
- });
- }
- catch (IllegalStateException x) {
- // TCF event dispatch is shutdown
- return;
- }
- catch (Exception x) {
- if (socket != LocatorService.this.socket) continue;
- Protocol.log("Cannot read from datagram socket", x);
- }
- }
- }
- };
-
- static {
- ServiceManager.addServiceProvider(new IServiceProvider() {
-
- public IService[] getLocalService(final IChannel channel) {
- channel.addCommandServer(locator, new IChannel.ICommandServer() {
- public void command(IToken token, String name, byte[] data) {
- locator.command((AbstractChannel)channel, token, name, data);
- }
- });
- return new IService[]{ locator };
- }
-
- public IService getServiceProxy(IChannel channel, String service_name) {
- return null;
- }
- });
- }
-
- public LocatorService() {
- locator = this;
- try {
- out_buf[0] = 'T';
- out_buf[1] = 'C';
- out_buf[2] = 'F';
- out_buf[3] = '1';
- out_buf[4] = 0;
- out_buf[5] = 0;
- out_buf[6] = 0;
- out_buf[7] = 0;
- try {
- socket = new DatagramSocket(DISCOVEY_PORT);
- }
- catch (BindException x) {
- socket = new DatagramSocket();
- }
- socket.setBroadcast(true);
- input_thread.setName("TCF Locator Receiver");
- timer_thread.setName("TCF Locator Timer");
- input_thread.setDaemon(true);
- timer_thread.setDaemon(true);
- input_thread.start();
- timer_thread.start();
- listeners.add(new LocatorListener() {
-
- public void peerAdded(IPeer peer) {
- sendPeerInfo(peer, null, 0);
- }
-
- public void peerChanged(IPeer peer) {
- sendPeerInfo(peer, null, 0);
- }
-
- public void peerHeartBeat(String id) {
- }
-
- public void peerRemoved(String id) {
- }
- });
- refreshSubNetList();
- sendPeerRequest(null, 0);
- }
- catch (Exception x) {
- Protocol.log("Cannot open UDP socket for TCF discovery protocol", x);
- }
- }
-
- public static LocalPeer getLocalPeer() {
- return local_peer;
- }
-
- public static Collection<LocatorListener> getListeners() {
- return listeners;
- }
-
- public static void addPeer(AbstractPeer peer) {
- assert peers.get(peer.getID()) == null;
- if (peer instanceof LocalPeer) local_peer = (LocalPeer)peer;
- peers.put(peer.getID(), peer);
- peer.sendPeerAddedEvent();
- }
-
- public static void removePeer(AbstractPeer peer) {
- String id = peer.getID();
- assert peers.get(id) == peer;
- peers.remove(id);
- peer.sendPeerRemovedEvent();
- }
-
- private Map<String,Object> makeErrorReport(int code, String msg) {
- Map<String,Object> err = new HashMap<String,Object>();
- err.put(IErrorReport.ERROR_TIME, new Long(System.currentTimeMillis()));
- err.put(IErrorReport.ERROR_CODE, new Integer(code));
- err.put(IErrorReport.ERROR_FORMAT, msg);
- return err;
- }
-
- private void command(final AbstractChannel channel, final IToken token, String name, byte[] data) {
- try {
- if (name.equals("redirect")) {
- String peer_id = (String)JSON.parseSequence(data)[0];
- IPeer peer = peers.get(peer_id);
- if (peer == null) {
- channel.sendResult(token, JSON.toJSONSequence(new Object[]{
- makeErrorReport(IErrorReport.TCF_ERROR_UNKNOWN_PEER, "Unknown peer ID") }));
- return;
- }
- channel.sendResult(token, JSON.toJSONSequence(new Object[]{ null }));
- if (peer instanceof LocalPeer) {
- channel.sendEvent(Protocol.getLocator(), "Hello", JSON.toJSONSequence(
- new Object[]{ channel.getLocalServices() }));
- return;
- }
- new ChannelProxy(channel, peer.openChannel());
- }
- else if (name.equals("sync")) {
- channel.sendResult(token, null);
- }
- else if (name.equals("getPeers")) {
- int i = 0;
- Object[] arr = new Object[peers.size()];
- for (IPeer p : peers.values()) arr[i++] = p.getAttributes();
- channel.sendResult(token, JSON.toJSONSequence(new Object[]{ null, arr }));
- }
- else {
- channel.rejectCommand(token);
- }
- }
- catch (Throwable x) {
- channel.terminate(x);
- }
- }
-
- private void refresh_timer() {
- long time = System.currentTimeMillis();
- /* Cleanup slave table */
- if (slaves.size() > 0) {
- int i = 0;
- while (i < slaves.size()) {
- Slave s = slaves.get(i);
- if (s.last_packet_time + DATA_RETENTION_PERIOD < time) {
- slaves.remove(i);
- }
- else {
- i++;
- }
- }
- }
- /* Cleanup peers table */
- ArrayList<RemotePeer> stale_peers = null;
- for (IPeer p : peers.values()) {
- if (p instanceof RemotePeer) {
- RemotePeer r = (RemotePeer)p;
- if (r.getLastUpdateTime() + DATA_RETENTION_PERIOD < time) {
- if (stale_peers == null) stale_peers = new ArrayList<RemotePeer>();
- stale_peers.add(r);
- }
- }
- }
- if (stale_peers != null) {
- IChannel[] open_channels = TransportManager.getOpenChannels();
- HashSet<IPeer> connected_peers = new HashSet<IPeer>();
- for (IChannel c : open_channels) connected_peers.add(c.getRemotePeer());
- for (RemotePeer p : stale_peers) {
- if (!connected_peers.contains(p)) p.dispose();
- }
- }
- /* Try to become a master */
- if (socket.getLocalPort() != DISCOVEY_PORT && last_master_packet_time + DATA_RETENTION_PERIOD / 2 <= time) {
- DatagramSocket s0 = socket;
- DatagramSocket s1 = null;
- try {
- s1 = new DatagramSocket(DISCOVEY_PORT);
- s1.setBroadcast(true);
- socket = s1;
- s0.close();
- }
- catch (Throwable x) {
- }
- }
- refreshSubNetList();
- for (SubNet subnet : subnets) subnet.beacon_ok = false;
- for (IPeer peer : peers.values()) sendPeerInfo(peer, null, 0);
- if (socket.getLocalPort() != DISCOVEY_PORT) sendSlavesBeacon();
- }
-
- private Slave addSlave(InetAddress addr, int port) {
- long time = System.currentTimeMillis();
- for (Slave s : slaves) {
- if (s.port == port && s.address.equals(addr)) {
- s.last_packet_time = time;
- return s;
- }
- }
- Slave s = new Slave(addr, port);
- s.last_packet_time = time;
- sendPeerRequest(addr, port);
- for (IPeer peer : peers.values()) sendPeerInfo(peer, addr, port);
- sendSlavesInfo(s);
- slaves.add(s);
- return s;
- }
-
- private void refreshSubNetList() {
- HashSet<SubNet> set = new HashSet<SubNet>();
- try {
- for (Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) {
- NetworkInterface f = e.nextElement();
- /* TODO: Class InterfaceAddress does not exists in Java versions before 1.6.
- * Fix the code below when support for old Java versions is not needed any more.
- */
- try {
- Method m0 = f.getClass().getMethod("getInterfaceAddresses");
- for (Object ia : (List<?>)m0.invoke(f)) {
- Method m1 = ia.getClass().getMethod("getNetworkPrefixLength");
- Method m2 = ia.getClass().getMethod("getAddress");
- Method m3 = ia.getClass().getMethod("getBroadcast");
- int network_prefix_len = (Short)m1.invoke(ia);
- InetAddress address = (InetAddress)m2.invoke(ia);
- InetAddress broadcast = (InetAddress)m3.invoke(ia);
- if (broadcast == null) broadcast = address;
- set.add(new SubNet(network_prefix_len, address, broadcast));
- }
- }
- catch (Exception x) {
- // Java 1.5 or older
- // TODO: need a better way to get broadcast addresses on Java 1.5 VM
- Enumeration<InetAddress> n = f.getInetAddresses();
- while (n.hasMoreElements()) {
- InetAddress addr = n.nextElement();
- byte[] buf = addr.getAddress();
- if (buf.length != 4) continue;
- buf[3] = (byte)255;
- try {
- set.add(new SubNet(24, addr, InetAddress.getByAddress(buf)));
- }
- catch (UnknownHostException y) {
- }
- }
- }
- }
- }
- catch (SocketException x) {
- Protocol.log("Cannot get list of network interfaces", x);
- }
- for (Iterator<SubNet> i = subnets.iterator(); i.hasNext();) {
- SubNet s = i.next();
- if (set.contains(s)) continue;
- i.remove();
- }
- for (Iterator<SubNet> i = set.iterator(); i.hasNext();) {
- SubNet s = i.next();
- if (subnets.contains(s)) continue;
- subnets.add(s);
- }
- }
-
- private void sendPeerRequest(InetAddress addr, int port) {
- try {
- out_buf[4] = CONF_REQ_INFO;
- if (addr == null) {
- for (SubNet subnet : subnets) {
- socket.send(new DatagramPacket(out_buf, 8, subnet.broadcast, DISCOVEY_PORT));
- }
- for (Slave slave : slaves) {
- socket.send(new DatagramPacket(out_buf, 8, slave.address, slave.port));
- }
- }
- else {
- socket.send(new DatagramPacket(out_buf, 8, addr, port));
- }
- }
- catch (Exception x) {
- Protocol.log("Cannot send datagram packet", x);
- }
- }
-
- private void sendPeerInfo(IPeer peer, InetAddress addr, int port) {
- if (peer instanceof RemotePeer) return;
- Map<String,String> attrs = peer.getAttributes();
- if (attrs.get(IPeer.ATTR_IP_HOST) == null) return;
- if (attrs.get(IPeer.ATTR_IP_PORT) == null) return;
- try {
- out_buf[4] = CONF_PEER_INFO;
- int i = 8;
- for (String key : attrs.keySet()) {
- String s = key + "=" + attrs.get(key);
- byte[] bt = s.getBytes("UTF-8");
- if (i + bt.length >= out_buf.length) break;
- System.arraycopy(bt, 0, out_buf, i, bt.length);
- i += bt.length;
- out_buf[i++] = 0;
- }
-
- InetAddress peer_addr = InetAddress.getByName(attrs.get(IPeer.ATTR_IP_HOST));
- for (SubNet subnet : subnets) {
- if (addr != null && !subnet.contains(addr)) continue;
- if (!subnet.contains(peer_addr)) continue;
- if (addr == null) {
- socket.send(new DatagramPacket(out_buf, i, subnet.broadcast, DISCOVEY_PORT));
- for (Slave slave : slaves) {
- if (!subnet.contains(slave.address)) continue;
- socket.send(new DatagramPacket(out_buf, i, slave.address, slave.port));
- }
- subnet.beacon_ok = true;
- }
- else {
- socket.send(new DatagramPacket(out_buf, i, addr, port));
- }
- }
- }
- catch (Exception x) {
- Protocol.log("Cannot send datagram packet", x);
- }
- }
-
- private void sendSlavesRequest(InetAddress addr, int port) {
- try {
- out_buf[4] = CONF_REQ_SLAVES;
- socket.send(new DatagramPacket(out_buf, 8, addr, port));
- }
- catch (Exception x) {
- Protocol.log("Cannot send datagram packet", x);
- }
- }
-
- private void sendSlavesInfo(Slave x) {
- try {
- long time = System.currentTimeMillis();
- out_buf[4] = CONF_SLAVES_INFO;
- int i = 8;
- if (x != null) {
- String s = x.port + ":" + x.address.getHostAddress();
- byte[] bt = s.getBytes("UTF-8");
- System.arraycopy(bt, 0, out_buf, i, bt.length);
- i += bt.length;
- out_buf[i++] = 0;
- }
- for (Slave y : slaves) {
- if (y.last_req_slaves_time + DATA_RETENTION_PERIOD < time) continue;
- socket.send(new DatagramPacket(out_buf, i, y.address, y.port));
- }
- }
- catch (Exception z) {
- Protocol.log("Cannot send datagram packet", z);
- }
- }
-
- private void sendSlavesInfo(InetAddress addr, int port, boolean only_linked) {
- try {
- long time = System.currentTimeMillis();
- out_buf[4] = CONF_SLAVES_INFO;
- int i = 8;
- for (SubNet n : subnets) {
- if (!n.contains(addr)) continue;
- for (Slave x : slaves) {
- if (x.port == port && x.address.equals(addr)) continue;
- if (!n.contains(x.address)) continue;
- if (only_linked && x.last_req_slaves_time + DATA_RETENTION_PERIOD < time) continue;
- String s = x.port + ":" + x.address.getHostAddress();
- byte[] bt = s.getBytes("UTF-8");
- if (i > 8 && i + bt.length >= PREF_PACKET_SIZE) {
- socket.send(new DatagramPacket(out_buf, i, addr, port));
- i = 8;
- }
- System.arraycopy(bt, 0, out_buf, i, bt.length);
- i += bt.length;
- out_buf[i++] = 0;
- }
- }
- if (i > 8) socket.send(new DatagramPacket(out_buf, i, addr, port));
- }
- catch (Exception x) {
- Protocol.log("Cannot send datagram packet", x);
- }
- }
-
- private void sendSlavesBeacon() {
- for (SubNet subnet : subnets) {
- if (subnet.beacon_ok) continue;
- try {
- out_buf[4] = CONF_SLAVES_INFO;
- socket.send(new DatagramPacket(out_buf, 8, subnet.broadcast, DISCOVEY_PORT));
- }
- catch (Exception x) {
- Protocol.log("Cannot send datagram packet", x);
- }
- }
- }
-
- private boolean isRemote(DatagramPacket p) {
- if (p.getPort() != socket.getLocalPort()) return true;
- InetAddress addr = p.getAddress();
- for (SubNet s : subnets) {
- if (s.address.equals(addr)) return false;
- }
- return true;
- }
-
- private void handleDatagramPacket(DatagramPacket p) {
- try {
- long time = System.currentTimeMillis();
- byte[] buf = p.getData();
- int len = p.getLength();
- if (len < 8) return;
- if (buf[0] != 'T') return;
- if (buf[1] != 'C') return;
- if (buf[2] != 'F') return;
- if (buf[3] != '1') return;
- if (isRemote(p)) {
- Slave sl = null;
- if (p.getPort() != DISCOVEY_PORT) {
- sl = addSlave(p.getAddress(), p.getPort());
- }
- switch (buf[4]) {
- case CONF_PEER_INFO:
- handlePeerInfoPacket(p);
- break;
- case CONF_REQ_INFO:
- handleReqInfoPacket(p);
- break;
- case CONF_SLAVES_INFO:
- handleSlavesInfoPacket(p);
- break;
- case CONF_REQ_SLAVES:
- sl.last_req_slaves_time = sl.last_packet_time;
- handleReqSlavesPacket(p);
- break;
- }
- if (socket.getLocalPort() != DISCOVEY_PORT) {
- for (SubNet s : subnets) {
- if (!s.contains(p.getAddress())) continue;
- if (s.last_slaves_req_time + DATA_RETENTION_PERIOD / 3 <= time) {
- sendSlavesRequest(p.getAddress(), p.getPort());
- s.last_slaves_req_time = time;
- }
- if (s.address.equals(p.getAddress())) last_master_packet_time = time;
- }
- }
- }
- }
- catch (Throwable x) {
- Protocol.log("Invalid datagram packet received", x);
- }
- }
-
- private void handlePeerInfoPacket(DatagramPacket p) {
- try {
- Map<String,String> map = new HashMap<String,String>();
- String s = new String(p.getData(), 8, p.getLength() - 8, "UTF-8");
- int l = s.length();
- int i = 0;
- while (i < l) {
- int i0 = i;
- while (i < l && s.charAt(i) != '=' && s.charAt(i) != 0) i++;
- int i1 = i;
- if (i < l && s.charAt(i) == '=') i++;
- int i2 = i;
- while (i < l && s.charAt(i) != 0) i++;
- int i3 = i;
- if (i < l && s.charAt(i) == 0) i++;
- String key = s.substring(i0, i1);
- String val = s.substring(i2, i3);
- map.put(key, val);
- }
- String id = map.get(IPeer.ATTR_ID);
- if (id == null) throw new Exception("Invalid peer info: no ID");
- IPeer peer = peers.get(id);
- if (peer instanceof RemotePeer) {
- ((RemotePeer)peer).updateAttributes(map);
- }
- else if (peer == null) {
- new RemotePeer(map);
- }
- }
- catch (Exception x) {
- Protocol.log("Invalid datagram packet received", x);
- }
- }
-
- private void handleReqInfoPacket(DatagramPacket p) {
- InetAddress addr = p.getAddress();
- int port = p.getPort();
- for (IPeer peer : peers.values()) {
- sendPeerInfo(peer, addr, port);
- }
- sendSlavesInfo(addr, port, true);
- }
-
- private void handleSlavesInfoPacket(DatagramPacket p) {
- try {
- String s = new String(p.getData(), 8, p.getLength() - 8, "UTF-8");
- int l = s.length();
- int i = 0;
- while (i < l) {
- int i0 = i;
- while (i < l && s.charAt(i) != ':' && s.charAt(i) != 0) i++;
- int i1 = i;
- if (i < l && s.charAt(i) == ':') i++;
- int i2 = i;
- while (i < l && s.charAt(i) != 0) i++;
- int i3 = i;
- if (i < l && s.charAt(i) == 0) i++;
- int port = Integer.parseInt(s.substring(i0, i1));
- if (port != DISCOVEY_PORT) {
- String host = s.substring(i2, i3);
- addSlave(InetAddress.getByName(host), port);
- }
- }
- }
- catch (Exception x) {
- Protocol.log("Invalid datagram packet received", x);
- }
- }
-
- private void handleReqSlavesPacket(DatagramPacket p) {
- sendSlavesInfo(p.getAddress(), p.getPort(), false);
- }
-
- /*----------------------------------------------------------------------------------*/
-
- public static LocatorService getLocator() {
- return locator;
- }
-
- public String getName() {
- return NAME;
- }
-
- public Map<String,IPeer> getPeers() {
- return peers;
- }
-
- public IToken redirect(String peer_id, DoneRedirect done) {
- throw new Error("Channel redirect cannot be done on local peer");
- }
-
- public IToken sync(DoneSync done) {
- throw new Error("Channel sync cannot be done on local peer");
- }
-
- public void addListener(LocatorListener listener) {
- listeners.add(listener);
- }
-
- public void removeListener(LocatorListener listener) {
- listeners.remove(listener);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/BreakpointsProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/BreakpointsProxy.java
deleted file mode 100644
index 683055ea7..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/BreakpointsProxy.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.remote;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.services.IBreakpoints;
-
-
-public class BreakpointsProxy implements IBreakpoints {
-
- private final IChannel channel;
- private final Map<BreakpointsListener,IChannel.IEventListener> listeners =
- new HashMap<BreakpointsListener,IChannel.IEventListener>();
-
- public BreakpointsProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public IToken set(Map<String,Object>[] properties, final DoneCommand done) {
- return new Command(channel, this, "set", new Object[]{ properties }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCommand(token, error);
- }
- }.token;
- }
-
- public IToken add(Map<String,Object> properties, final DoneCommand done) {
- return new Command(channel, this, "add", new Object[]{ properties }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCommand(token, error);
- }
- }.token;
- }
-
- public IToken change(Map<String,Object> properties, final DoneCommand done) {
- return new Command(channel, this, "change", new Object[]{ properties }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCommand(token, error);
- }
- }.token;
- }
-
- public IToken disable(String[] ids, final DoneCommand done) {
- return new Command(channel, this, "disable", new Object[]{ ids }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCommand(token, error);
- }
- }.token;
- }
-
- public IToken enable(String[] ids, final DoneCommand done) {
- return new Command(channel, this, "enable", new Object[]{ ids }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCommand(token, error);
- }
- }.token;
- }
-
- public IToken remove(String[] ids, final DoneCommand done) {
- return new Command(channel, this, "remove", new Object[]{ ids }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCommand(token, error);
- }
- }.token;
- }
-
- public IToken getIDs(final DoneGetIDs done) {
- return new Command(channel, this, "getIDs", null) {
- @Override
- public void done(Exception error, Object[] args) {
- String[] arr = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- arr = toStringArray(args[1]);
- }
- done.doneGetIDs(token, error, arr);
- }
- }.token;
- }
-
- public IToken getProperties(String id, final DoneGetProperties done) {
- return new Command(channel, this, "getProperties", new Object[]{ id }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- Map<String,Object> map = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- map = (Map<String,Object>)args[1];
- }
- done.doneGetProperties(token, error, map);
- }
- }.token;
- }
-
- public IToken getStatus(String id, final DoneGetStatus done) {
- return new Command(channel, this, "getStatus", new Object[]{ id }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- Map<String,Object> map = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- map = (Map<String,Object>)args[1];
- }
- done.doneGetStatus(token, error, map);
- }
- }.token;
- }
-
- public IToken getCapabilities(String id, final DoneGetCapabilities done) {
- return new Command(channel, this, "getCapabilities", new Object[]{ id }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- Map<String,Object> map = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- map = (Map<String,Object>)args[1];
- }
- done.doneGetCapabilities(token, error, map);
- }
- }.token;
- }
-
- public String getName() {
- return NAME;
- }
-
- @SuppressWarnings("unchecked")
- private String[] toStringArray(Object o) {
- if (o == null) return null;
- Collection<String> c = (Collection<String>)o;
- return (String[])c.toArray(new String[c.size()]);
- }
-
- @SuppressWarnings("unchecked")
- private Map<String,Object>[] toBreakpointArray(Object o) {
- if (o == null) return null;
- Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o;
- return (Map<String,Object>[])c.toArray(new Map[c.size()]);
- }
-
- public void addListener(final BreakpointsListener listener) {
- IChannel.IEventListener l = new IChannel.IEventListener() {
-
- @SuppressWarnings("unchecked")
- public void event(String name, byte[] data) {
- try {
- Object[] args = JSON.parseSequence(data);
- if (name.equals("status")) {
- assert args.length == 2;
- listener.breakpointStatusChanged((String)args[0], (Map<String,Object>)args[1]);
- }
- else if (name.equals("contextAdded")) {
- assert args.length == 1;
- listener.contextAdded(toBreakpointArray(args[0]));
- }
- else if (name.equals("contextChanged")) {
- assert args.length == 1;
- listener.contextChanged(toBreakpointArray(args[0]));
- }
- else if (name.equals("contextRemoved")) {
- assert args.length == 1;
- listener.contextRemoved(toStringArray(args[0]));
- }
- else {
- throw new IOException("Breakpoints service: unknown event: " + name);
- }
- }
- catch (Throwable x) {
- channel.terminate(x);
- }
- }
- };
- channel.addEventListener(this, l);
- listeners.put(listener, l);
- }
-
- public void removeListener(BreakpointsListener listener) {
- IChannel.IEventListener l = listeners.remove(listener);
- if (l != null) channel.removeEventListener(this, l);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/DiagnosticsProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/DiagnosticsProxy.java
deleted file mode 100644
index e3a5dd8cb..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/DiagnosticsProxy.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.remote;
-
-import java.math.BigDecimal;
-import java.util.Collection;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.services.IDiagnostics;
-
-
-public class DiagnosticsProxy implements IDiagnostics {
-
- private final IChannel channel;
-
- private static class Symbol implements ISymbol {
-
- private final Map<String,Object> props;
-
- Symbol(Map<String,Object> props) {
- this.props = props;
- }
-
- public String getSectionName() {
- return (String)props.get("Section");
- }
-
- public Number getValue() {
- return (Number)props.get("Value");
- }
-
- public boolean isAbs() {
- Boolean b = (Boolean)props.get("Abs");
- return b != null && b.booleanValue();
- }
-
- public boolean isCommon() {
- String s = (String)props.get("Storage");
- return s != null && s.equals("COMMON");
- }
-
- public boolean isGlobal() {
- String s = (String)props.get("Storage");
- return s != null && s.equals("GLOBAL");
- }
-
- public boolean isLocal() {
- String s = (String)props.get("Storage");
- return s != null && s.equals("LOCAL");
- }
-
- public boolean isUndef() {
- String s = (String)props.get("Storage");
- return s != null && s.equals("UNDEF");
- }
- }
-
- public DiagnosticsProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public String getName() {
- return NAME;
- }
-
- public IToken echo(String s, final DoneEcho done) {
- return new Command(channel, this, "echo", new Object[]{ s }) {
- @Override
- public void done(Exception error, Object[] args) {
- String str = null;
- if (error == null) {
- assert args.length == 1;
- str = (String)args[0];
- }
- done.doneEcho(token, error, str);
- }
- }.token;
- }
-
- public IToken echoFP(BigDecimal n, final DoneEchoFP done) {
- return new Command(channel, this, "echoFP", new Object[]{ n }) {
- @Override
- public void done(Exception error, Object[] args) {
- BigDecimal n = null;
- if (error == null) {
- assert args.length == 1;
- Number x = (Number)args[0];
- if (x instanceof BigDecimal) {
- n = (BigDecimal)x;
- }
- else {
- n = new BigDecimal(x.toString());
- }
- }
- done.doneEchoFP(token, error, n);
- }
- }.token;
- }
-
- public IToken getTestList(final DoneGetTestList done) {
- return new Command(channel, this, "getTestList", null) {
- @Override
- public void done(Exception error, Object[] args) {
- String[] arr = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- arr = toStringArray(args[1]);
- }
- done.doneGetTestList(token, error, arr);
- }
- }.token;
- }
-
- public IToken runTest(String s, final DoneRunTest done) {
- return new Command(channel, this, "runTest", new Object[]{ s }) {
- @Override
- public void done(Exception error, Object[] args) {
- String str = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- str = (String)args[1];
- }
- done.doneRunTest(token, error, str);
- }
- }.token;
- }
-
- public IToken cancelTest(String s, final DoneCancelTest done) {
- return new Command(channel, this, "cancelTest", new Object[]{ s }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCancelTest(token, error);
- }
- }.token;
- }
-
- public IToken getSymbol(String context_id, String symbol_name, final DoneGetSymbol done) {
- return new Command(channel, this, "getSymbol", new Object[]{ context_id, symbol_name }) {
- @Override
- public void done(Exception error, Object[] args) {
- ISymbol sym = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- sym = toSymbol(args[1]);
- }
- done.doneGetSymbol(token, error, sym);
- }
- }.token;
- }
-
- public IToken createTestStreams(int inp_buf_size, int out_buf_size, final DoneCreateTestStreams done) {
- return new Command(channel, this, "createTestStreams", new Object[]{ inp_buf_size, out_buf_size }) {
- @Override
- public void done(Exception error, Object[] args) {
- String inp_id = null;
- String out_id = null;
- if (error == null) {
- assert args.length == 3;
- error = toError(args[0]);
- inp_id = (String)args[1];
- out_id = (String)args[2];
- }
- done.doneCreateTestStreams(token, error, inp_id, out_id);
- }
- }.token;
- }
-
- public IToken disposeTestStream(String id, final DoneDisposeTestStream done) {
- return new Command(channel, this, "disposeTestStream", new Object[]{ id }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneDisposeTestStream(token, error);
- }
- }.token;
- }
-
- public IToken not_implemented_command(final DoneNotImplementedCommand done) {
- return new Command(channel, this, "not implemented command", null) {
- @Override
- public void done(Exception error, Object[] args) {
- done.doneNotImplementedCommand(token, error);
- }
- }.token;
- }
-
- @SuppressWarnings("unchecked")
- private String[] toStringArray(Object o) {
- if (o == null) return null;
- Collection<String> c = (Collection<String>)o;
- return (String[])c.toArray(new String[c.size()]);
- }
-
- @SuppressWarnings("unchecked")
- private ISymbol toSymbol(Object o) {
- if (o == null) return null;
- return new Symbol((Map<String,Object>)o);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ExpressionsProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ExpressionsProxy.java
deleted file mode 100644
index 9e31ea558..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ExpressionsProxy.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.tm.internal.tcf.services.remote;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Base64;
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.services.IExpressions;
-import org.eclipse.tm.tcf.services.ISymbols.TypeClass;;
-
-public class ExpressionsProxy implements IExpressions {
-
- private final IChannel channel;
- private final Map<ExpressionsListener,IChannel.IEventListener> listeners =
- new HashMap<ExpressionsListener,IChannel.IEventListener>();
-
- private class Context implements Expression {
-
- private final Map<String,Object> props;
-
- Context(Map<String,Object> props) {
- this.props = props;
- }
-
- public boolean canAssign() {
- Boolean n = (Boolean)props.get(PROP_CAN_ASSIGN);
- if (n == null) return false;
- return n.booleanValue();
- }
-
- public int getBits() {
- Number n = (Number)props.get(PROP_BITS);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public String getExpression() {
- return (String)props.get(PROP_EXPRESSION);
- }
-
- public String getID() {
- return (String)props.get(PROP_ID);
- }
-
- public String getLanguage() {
- return (String)props.get(PROP_LANGUAGE);
- }
-
- public String getParentID() {
- return (String)props.get(PROP_PARENT_ID);
- }
-
- public Map<String, Object> getProperties() {
- return props;
- }
-
- public int getSize() {
- Number n = (Number)props.get(PROP_SIZE);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public String getTypeID() {
- return (String)props.get(PROP_TYPE);
- }
- }
-
- private class ContextValue implements Value {
-
- private final byte[] value;
- private final Map<String,Object> props;
-
- ContextValue(byte[] value, Map<String,Object> props) {
- if (props == null) props = new HashMap<String,Object>();
- this.value = value;
- this.props = props;
- }
-
- public Map<String, Object> getProperties() {
- return props;
- }
-
- public String getTypeID() {
- return (String)props.get(VAL_TYPE);
- }
-
- public String getExeContextID() {
- return (String)props.get(VAL_EXE_ID);
- }
-
- public byte[] getValue() {
- return value;
- }
-
- public TypeClass getTypeClass() {
- Number n = (Number)props.get(VAL_CLASS);
- if (n != null) {
- switch (n.intValue()) {
- case 1: return TypeClass.cardinal;
- case 2: return TypeClass.integer;
- case 3: return TypeClass.real;
- case 4: return TypeClass.pointer;
- case 5: return TypeClass.array;
- case 6: return TypeClass.composite;
- case 7: return TypeClass.enumeration;
- case 8: return TypeClass.function;
- }
- }
- return TypeClass.unknown;
- }
-
- public boolean isBigEndian() {
- Boolean n = (Boolean)props.get(VAL_BIG_ENDIAN);
- if (n == null) return false;
- return n.booleanValue();
- }
- }
-
- public ExpressionsProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public IToken assign(String id, byte[] value, final DoneAssign done) {
- return new Command(channel, this, "assign", new Object[]{ id, Base64.toBase64(value, 0, value.length) }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneAssign(token, error);
- }
- }.token;
- }
-
- public IToken create(String parent_id, String language, String expression, final DoneCreate done) {
- return new Command(channel, this, "create", new Object[]{ parent_id, language, expression }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- Context ctx = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- if (args[1] != null) ctx = new Context((Map<String,Object>)args[1]);
- }
- done.doneCreate(token, error, ctx);
- }
- }.token;
- }
-
- public IToken dispose(String id, final DoneDispose done) {
- return new Command(channel, this, "dispose", new Object[]{ id }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneDispose(token, error);
- }
- }.token;
- }
-
- public IToken evaluate(String id, final DoneEvaluate done) {
- return new Command(channel, this, "evaluate", new Object[]{ id }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- byte[] value = null;
- Map<String,Object> props = null;
- if (error == null) {
- assert args.length == 3;
- if (args[0] != null) value = Base64.toByteArray(((String)args[0]).toCharArray());
- error = toError(args[1]);
- props = (Map<String,Object>)args[2];
- }
- done.doneEvaluate(token, error, new ContextValue(value, props));
- }
- }.token;
- }
-
- public IToken getChildren(String parent_context_id, final DoneGetChildren done) {
- return new Command(channel, this, "getChildren", new Object[]{ parent_context_id }) {
- @Override
- public void done(Exception error, Object[] args) {
- String[] lst = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- lst = toStringArray(args[1]);
- }
- done.doneGetChildren(token, error, lst);
- }
- }.token;
- }
-
- public IToken getContext(String id, final DoneGetContext done) {
- return new Command(channel, this, "getContext", new Object[]{ id }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- Context ctx = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- if (args[1] != null) ctx = new Context((Map<String,Object>)args[1]);
- }
- done.doneGetContext(token, error, ctx);
- }
- }.token;
- }
-
- public String getName() {
- return NAME;
- }
-
- public void addListener(final ExpressionsListener listener) {
- IChannel.IEventListener l = new IChannel.IEventListener() {
-
- public void event(String name, byte[] data) {
- try {
- Object[] args = JSON.parseSequence(data);
- if (name.equals("valueChanged")) {
- assert args.length == 1;
- listener.valueChanged((String)args[0]);
- }
- else {
- throw new IOException("Expressions service: unknown event: " + name);
- }
- }
- catch (Throwable x) {
- channel.terminate(x);
- }
- }
- };
- channel.addEventListener(this, l);
- listeners.put(listener, l);
- }
-
- public void removeListener(ExpressionsListener listener) {
- IChannel.IEventListener l = listeners.remove(listener);
- if (l != null) channel.removeEventListener(this, l);
- }
-
- @SuppressWarnings("unchecked")
- private String[] toStringArray(Object o) {
- if (o == null) return null;
- Collection<String> c = (Collection<String>)o;
- return (String[])c.toArray(new String[c.size()]);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/FileSystemProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/FileSystemProxy.java
deleted file mode 100644
index 0f6a64144..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/FileSystemProxy.java
+++ /dev/null
@@ -1,596 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.remote;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Base64;
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IErrorReport;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.services.IFileSystem;
-
-
-public class FileSystemProxy implements IFileSystem {
-
- private final class FileHandle implements IFileHandle {
- final String id;
-
- FileHandle(String id) {
- this.id = id;
- }
-
- public IFileSystem getService() {
- return FileSystemProxy.this;
- }
-
- public String toString() {
- return "[File Handle '" + id + "']";
- }
- }
-
- private static final class Status extends FileSystemException implements IErrorReport {
-
- private static final long serialVersionUID = -1636567076145085980L;
-
- private final int status;
- private final Map<String,Object> attrs;
-
- Status(int status, String message, Map<String,Object> attrs) {
- super(message);
- this.status = status;
- this.attrs = attrs;
- }
-
- Status(Exception x) {
- super(x);
- this.status = IErrorReport.TCF_ERROR_OTHER;
- this.attrs = new HashMap<String,Object>();
- }
-
- public int getStatus() {
- return status;
- }
-
- public int getErrorCode() {
- Number n = (Number)attrs.get(ERROR_CODE);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public int getAltCode() {
- Number n = (Number)attrs.get(ERROR_ALT_CODE);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public String getAltOrg() {
- return (String)attrs.get(ERROR_ALT_ORG);
- }
-
- public Map<String, Object> getAttributes() {
- return attrs;
- }
- }
-
- private abstract class FileSystemCommand extends Command {
-
- FileSystemCommand(String command, Object[] args) {
- super(channel, FileSystemProxy.this, command, args);
- }
-
- @SuppressWarnings("unchecked")
- public Status toFSError(Object data) {
- if (data == null) return null;
- Map<String,Object> map = (Map<String,Object>)data;
- Number error_code = (Number)map.get(IErrorReport.ERROR_CODE);
- String cmd = getCommandString();
- if (cmd.length() > 72) cmd = cmd.substring(0, 72) + "...";
- Status s = new Status(error_code.intValue(),
- "TCF command exception:" +
- "\nCommand: " + cmd +
- "\nException: " + toErrorString(data) +
- "\nError code: " + error_code, map);
- Object caused_by = map.get(IErrorReport.ERROR_CAUSED_BY);
- if (caused_by != null) s.initCause(toError(caused_by, false));
- return s;
- }
- }
-
- private final IChannel channel;
-
- public FileSystemProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public IToken close(IFileHandle handle, final DoneClose done) {
- assert handle.getService() == this;
- String id = ((FileHandle)handle).id;
- return new FileSystemCommand("close", new Object[]{ id }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 1;
- s = toFSError(args[0]);
- }
- done.doneClose(token, s);
- }
- }.token;
- }
-
- public IToken setstat(String path, FileAttrs attrs, final DoneSetStat done) {
- Object dt = toObject(attrs);
- return new FileSystemCommand("setstat", new Object[]{ path, dt }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 1;
- s = toFSError(args[0]);
- }
- done.doneSetStat(token, s);
- }
- }.token;
- }
-
- public IToken fsetstat(IFileHandle handle, FileAttrs attrs, final DoneSetStat done) {
- assert handle.getService() == this;
- String id = ((FileHandle)handle).id;
- Object dt = toObject(attrs);
- return new FileSystemCommand("fsetstat", new Object[]{ id, dt }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 1;
- s = toFSError(args[0]);
- }
- done.doneSetStat(token, s);
- }
- }.token;
- }
-
- public IToken stat(String path, final DoneStat done) {
- return new FileSystemCommand("stat", new Object[]{ path }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- FileAttrs a = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 2;
- s = toFSError(args[0]);
- if (s == null) a = toFileAttrs(args[1]);
- }
- done.doneStat(token, s, a);
- }
- }.token;
- }
-
- public IToken fstat(IFileHandle handle, final DoneStat done) {
- assert handle.getService() == this;
- String id = ((FileHandle)handle).id;
- return new FileSystemCommand("fstat", new Object[]{ id }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- FileAttrs a = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 2;
- s = toFSError(args[0]);
- if (s == null) a = toFileAttrs(args[1]);
- }
- done.doneStat(token, s, a);
- }
- }.token;
- }
-
- public IToken lstat(String path, final DoneStat done) {
- return new FileSystemCommand("lstat", new Object[]{ path }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- FileAttrs a = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 2;
- s = toFSError(args[0]);
- if (s == null) a = toFileAttrs(args[1]);
- }
- done.doneStat(token, s, a);
- }
- }.token;
- }
-
- public IToken mkdir(String path, FileAttrs attrs, final DoneMkDir done) {
- Object dt = toObject(attrs);
- return new FileSystemCommand("mkdir", new Object[]{ path, dt }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 1;
- s = toFSError(args[0]);
- }
- done.doneMkDir(token, s);
- }
- }.token;
- }
-
- public IToken open(String file_name, int flags, FileAttrs attrs, final DoneOpen done) {
- Object dt = toObject(attrs);
- return new FileSystemCommand("open", new Object[]{ file_name, new Integer(flags), dt }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- FileHandle h = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 2;
- s = toFSError(args[0]);
- if (s == null) h = toFileHandle(args[1]);
- }
- done.doneOpen(token, s, h);
- }
- }.token;
- }
-
- public IToken opendir(String path, final DoneOpen done) {
- return new FileSystemCommand("opendir", new Object[]{ path }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- FileHandle h = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 2;
- s = toFSError(args[0]);
- if (s == null) h = toFileHandle(args[1]);
- }
- done.doneOpen(token, s, h);
- }
- }.token;
- }
-
- public IToken read(IFileHandle handle, long offset, int len, final DoneRead done) {
- assert handle.getService() == this;
- String id = ((FileHandle)handle).id;
- return new FileSystemCommand("read", new Object[]{
- id, Long.valueOf(offset), Integer.valueOf(len) }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- byte[] b = null;
- boolean eof = false;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 3;
- s = toFSError(args[1]);
- if (s == null) {
- String str = (String)args[0];
- if (str != null) b = Base64.toByteArray(str.toCharArray());
- eof = ((Boolean)args[2]).booleanValue();
- }
- }
- done.doneRead(token, s, b, eof);
- }
- }.token;
- }
-
- public IToken readdir(IFileHandle handle, final DoneReadDir done) {
- assert handle.getService() == this;
- String id = ((FileHandle)handle).id;
- return new FileSystemCommand("readdir", new Object[]{ id }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- DirEntry[] b = null;
- boolean eof = false;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 3;
- s = toFSError(args[1]);
- if (s == null) {
- b = toDirEntryArray(args[0]);
- eof = ((Boolean)args[2]).booleanValue();
- }
- }
- done.doneReadDir(token, s, b, eof);
- }
- }.token;
- }
-
- public IToken roots(final DoneRoots done) {
- return new FileSystemCommand("roots", null) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- DirEntry[] b = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 2;
- s = toFSError(args[1]);
- if (s == null) b = toDirEntryArray(args[0]);
- }
- done.doneRoots(token, s, b);
- }
- }.token;
- }
-
- public IToken readlink(String path, final DoneReadLink done) {
- return new FileSystemCommand("readlink", new Object[]{ path }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- String p = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 2;
- s = toFSError(args[0]);
- if (s == null) p = (String)args[1];
- }
- done.doneReadLink(token, s, p);
- }
- }.token;
- }
-
- public IToken realpath(String path, final DoneRealPath done) {
- return new FileSystemCommand("realpath", new Object[]{ path }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- String p = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 2;
- s = toFSError(args[0]);
- if (s == null) p = (String)args[1];
- }
- done.doneRealPath(token, s, p);
- }
- }.token;
- }
-
- public IToken remove(String file_name, final DoneRemove done) {
- return new FileSystemCommand("remove", new Object[]{ file_name }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 1;
- s = toFSError(args[0]);
- }
- done.doneRemove(token, s);
- }
- }.token;
- }
-
- public IToken rename(String old_path, String new_path, final DoneRename done) {
- return new FileSystemCommand("rename", new Object[]{ old_path, new_path }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 1;
- s = toFSError(args[0]);
- }
- done.doneRename(token, s);
- }
- }.token;
- }
-
- public IToken rmdir(String path, final DoneRemove done) {
- return new FileSystemCommand("rmdir", new Object[]{ path }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 1;
- s = toFSError(args[0]);
- }
- done.doneRemove(token, s);
- }
- }.token;
- }
-
- public IToken symlink(String link_path, String target_path, final DoneSymLink done) {
- return new FileSystemCommand("symlink", new Object[]{ link_path, target_path }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 1;
- s = toFSError(args[0]);
- }
- done.doneSymLink(token, s);
- }
- }.token;
- }
-
- public IToken write(IFileHandle handle, long offset, byte[] data,
- int data_pos, int data_size, final DoneWrite done) {
- assert handle.getService() == this;
- String id = ((FileHandle)handle).id;
- return new FileSystemCommand("write", new Object[]{
- id, Long.valueOf(offset), Base64.toBase64(data, data_pos, data_size) }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 1;
- s = toFSError(args[0]);
- }
- done.doneWrite(token, s);
- }
- }.token;
- }
-
- public IToken copy(String src_path, String dst_path,
- boolean copy_permissions, boolean copy_uidgid, final DoneCopy done) {
- return new FileSystemCommand("copy", new Object[]{
- src_path, dst_path, Boolean.valueOf(copy_permissions),
- Boolean.valueOf(copy_uidgid) }) {
- public void done(Exception error, Object[] args) {
- Status s = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 1;
- s = toFSError(args[0]);
- }
- done.doneCopy(token, s);
- }
- }.token;
- }
-
- public IToken user(final DoneUser done) {
- return new FileSystemCommand("user", null) {
- @Override
- public void done(Exception error, Object[] args) {
- Status s = null;
- int r_uid = 0;
- int e_uid = 0;
- int r_gid = 0;
- int e_gid = 0;
- String home = null;
- if (error != null) {
- s = new Status(error);
- }
- else {
- assert args.length == 5;
- r_uid = ((Number)args[0]).intValue();
- e_uid = ((Number)args[1]).intValue();
- r_gid = ((Number)args[2]).intValue();
- e_gid = ((Number)args[3]).intValue();
- home = (String)args[4];
- }
- done.doneUser(token, s, r_uid, e_uid, r_gid, e_gid, home);
- }
- }.token;
- }
-
- public String getName() {
- return NAME;
- }
-
- private Object toObject(FileAttrs attrs) {
- if (attrs == null) return null;
- Map<String,Object> m = new HashMap<String,Object>();
- if (attrs.attributes != null) m.putAll(attrs.attributes);
- if ((attrs.flags & ATTR_SIZE) != 0) {
- m.put("Size", Long.valueOf(attrs.size));
- }
- if ((attrs.flags & ATTR_UIDGID) != 0) {
- m.put("UID", Integer.valueOf(attrs.uid));
- m.put("GID", Integer.valueOf(attrs.gid));
- }
- if ((attrs.flags & ATTR_PERMISSIONS) != 0) {
- m.put("Permissions", Integer.valueOf(attrs.permissions));
- }
- if ((attrs.flags & ATTR_ACMODTIME) != 0) {
- m.put("ATime", Long.valueOf(attrs.atime));
- m.put("MTime", Long.valueOf(attrs.mtime));
- }
- return m;
- }
-
- @SuppressWarnings("unchecked")
- private FileAttrs toFileAttrs(Object o) {
- if (o == null) return null;
- Map<String,Object> m = new HashMap<String,Object>((Map<String,Object>)o);
- int flags = 0;
- long size = 0;
- int uid = 0;
- int gid = 0;
- int permissions = 0;
- long atime = 0;
- long mtime = 0;
- Number n = (Number)m.remove("Size");
- if (n != null) {
- size = n.longValue();
- flags |= ATTR_SIZE;
- }
- Number n1 = (Number)m.remove("UID");
- Number n2 = (Number)m.remove("GID");
- if (n1 != null && n2 != null) {
- uid = n1.intValue();
- gid = n2.intValue();
- flags |= ATTR_UIDGID;
- }
- n = (Number)m.remove("Permissions");
- if (n != null) {
- permissions = n.intValue();
- flags |= ATTR_PERMISSIONS;
- }
- n1 = (Number)m.remove("ATime");
- n2 = (Number)m.remove("MTime");
- if (n1 != null && n2 != null) {
- atime = n1.longValue();
- mtime = n2.longValue();
- flags |= ATTR_ACMODTIME;
- }
- return new FileAttrs(flags, size, uid, gid, permissions, atime, mtime, m);
- }
-
- private FileHandle toFileHandle(Object o) {
- if (o == null) return null;
- return new FileHandle(o.toString());
- }
-
- @SuppressWarnings("unchecked")
- private DirEntry[] toDirEntryArray(Object o) {
- if (o == null) return null;
- Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o;
- DirEntry[] res = new DirEntry[c.size()];
- int i = 0;
- for (Map<String,Object> m : c) {
- res[i++] = new DirEntry(
- (String)m.get("FileName"),
- (String)m.get("LongName"),
- toFileAttrs(m.get("Attrs")));
- }
- return res;
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/GenericProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/GenericProxy.java
deleted file mode 100644
index 99df14426..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/GenericProxy.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.remote;
-
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IService;
-
-/**
- * Objects of GenericProxy class represent remote services, which don't
- * have a proxy class defined for them.
- * Clients still can use such services, but framework will not provide
- * service specific utility methods for message formatting and parsing.
- */
-public class GenericProxy implements IService {
-
- private final IChannel channel;
- private final String name;
-
- public GenericProxy(IChannel channel, String name) {
- this.channel = channel;
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public IChannel getChannel() {
- return channel;
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/LineNumbersProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/LineNumbersProxy.java
deleted file mode 100644
index 3263e2dbe..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/LineNumbersProxy.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.eclipse.tm.internal.tcf.services.remote;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.services.ILineNumbers;
-
-
-public class LineNumbersProxy implements ILineNumbers {
-
- private final IChannel channel;
-
- public LineNumbersProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public String getName() {
- return NAME;
- }
-
- public IToken mapToSource(String context_id, Number start_address,
- Number end_address, final DoneMapToSource done) {
- return new Command(channel, this, "mapToSource", new Object[]{ context_id,
- start_address, end_address }) {
- @Override
- public void done(Exception error, Object[] args) {
- CodeArea[] arr = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- arr = toTextAreaArray(args[1]);
- }
- done.doneMapToSource(token, error, arr);
- }
- }.token;
- }
-
- private static int getInteger(Map<String,Object> map, String name, int def) {
- Number n = (Number)map.get(name);
- if (n == null) return def;
- return n.intValue();
- }
-
- private static String getString(Map<String,Object> map, String name, String def) {
- String s = (String)map.get(name);
- if (s == null) return def;
- return s;
- }
-
- private static boolean getBoolean(Map<String,Object> map, String name) {
- Boolean b = (Boolean)map.get(name);
- if (b == null) return false;
- return b.booleanValue();
- }
-
- @SuppressWarnings("unchecked")
- private CodeArea[] toTextAreaArray(Object o) {
- if (o == null) return null;
- Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o;
- int n = 0;
- CodeArea[] arr = new CodeArea[c.size()];
- String directory = null;
- String file = null;
- for (Map<String,Object> area : c) {
- directory = getString(area, "Dir", directory);
- file = getString(area, "File", file);
- arr[n++] = new CodeArea(directory, file,
- getInteger(area, "SLine", 0), getInteger(area, "SCol", 0),
- getInteger(area, "ELine", 0), getInteger(area, "ECol", 0),
- (Number)area.get("SAddr"), (Number)area.get("EAddr"),
- getInteger(area, "ISA", 0),
- getBoolean(area, "IsStmt"), getBoolean(area, "BasicBlock"),
- getBoolean(area, "PrologueEnd"), getBoolean(area, "EpilogueBegin"));
- }
- return arr;
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/LocatorProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/LocatorProxy.java
deleted file mode 100644
index 8c72d8960..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/LocatorProxy.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.remote;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IPeer;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.protocol.Protocol;
-import org.eclipse.tm.tcf.services.ILocator;
-
-
-public class LocatorProxy implements ILocator {
-
- private final IChannel channel;
- private final Map<String,IPeer> peers = new HashMap<String,IPeer>();
- private final Collection<LocatorListener> listeners = new ArrayList<LocatorListener>();
-
- private boolean get_peers_done = false;
-
- private class Peer implements IPeer {
-
- private final IPeer parent;
-
- private final Map<String, String> attrs;
-
- Peer(IPeer parent, Map<String,String> attrs) {
- this.parent = parent;
- this.attrs = attrs;
- }
-
- public Map<String, String> getAttributes() {
- assert Protocol.isDispatchThread();
- return attrs;
- }
-
- public String getID() {
- assert Protocol.isDispatchThread();
- return attrs.get(ATTR_ID);
- }
-
- public String getName() {
- assert Protocol.isDispatchThread();
- return attrs.get(ATTR_NAME);
- }
-
- public String getOSName() {
- assert Protocol.isDispatchThread();
- return attrs.get(ATTR_OS_NAME);
- }
-
- public String getTransportName() {
- assert Protocol.isDispatchThread();
- return attrs.get(ATTR_TRANSPORT_NAME);
- }
-
- public IChannel openChannel() {
- assert Protocol.isDispatchThread();
- IChannel c = parent.openChannel();
- c.redirect(getID());
- return c;
- }
- };
-
- private final IChannel.IEventListener event_listener = new IChannel.IEventListener() {
-
- @SuppressWarnings("unchecked")
- public void event(String name, byte[] data) {
- try {
- Object[] args = JSON.parseSequence(data);
- if (name.equals("peerAdded")) {
- assert args.length == 1;
- IPeer peer = new Peer(channel.getRemotePeer(), (Map<String,String>)args[0]);
- if (peers.get(peer.getID()) != null) {
- Protocol.log("Invalid peerAdded event", new Error());
- return;
- }
- peers.put(peer.getID(), peer);
- for (LocatorListener l : listeners.toArray(new LocatorListener[listeners.size()])) {
- try {
- l.peerAdded(peer);
- }
- catch (Throwable x) {
- Protocol.log("Unhandled exception in Locator listener", x);
- }
- }
- }
- else if (name.equals("peerChanged")) {
- assert args.length == 1;
- Map<String,String> m = (Map<String,String>)args[0];
- if (m == null) throw new Error("Locator service: invalid peerChanged event - no peer ID");
- IPeer peer = peers.get(m.get(IPeer.ATTR_ID));
- if (peer == null) return;
- peers.put(peer.getID(), peer);
- for (LocatorListener l : listeners.toArray(new LocatorListener[listeners.size()])) {
- try {
- l.peerChanged(peer);
- }
- catch (Throwable x) {
- Protocol.log("Unhandled exception in Locator listener", x);
- }
- }
- }
- else if (name.equals("peerRemoved")) {
- assert args.length == 1;
- String id = (String)args[0];
- IPeer peer = peers.remove(id);
- if (peer == null) return;
- for (LocatorListener l : listeners.toArray(new LocatorListener[listeners.size()])) {
- try {
- l.peerRemoved(id);
- }
- catch (Throwable x) {
- Protocol.log("Unhandled exception in Locator listener", x);
- }
- }
- }
- else if (name.equals("peerHeartBeat")) {
- assert args.length == 1;
- String id = (String)args[0];
- IPeer peer = peers.get(id);
- if (peer == null) return;
- for (LocatorListener l : listeners.toArray(new LocatorListener[listeners.size()])) {
- try {
- l.peerHeartBeat(id);
- }
- catch (Throwable x) {
- Protocol.log("Unhandled exception in Locator listener", x);
- }
- }
- }
- else {
- throw new IOException("Locator service: unknown event: " + name);
- }
- }
- catch (Throwable x) {
- channel.terminate(x);
- }
- }
- };
-
- public LocatorProxy(IChannel channel) {
- this.channel = channel;
- channel.addEventListener(this, event_listener);
- }
-
- public String getName() {
- return NAME;
- }
-
- public Map<String,IPeer> getPeers() {
- return peers;
- }
-
- public IToken redirect(String peer_id, final DoneRedirect done) {
- return new Command(channel, this, "redirect", new Object[]{ peer_id }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneRedirect(token, error);
- }
- }.token;
- }
-
- public IToken sync(final DoneSync done) {
- return new Command(channel, this, "sync", null) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error != null) channel.terminate(error);
- done.doneSync(token);
- }
- }.token;
- }
-
- public void addListener(LocatorListener listener) {
- listeners.add(listener);
- if (!get_peers_done) {
- new Command(channel, this, "getPeers", null) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- }
- if (error != null) {
- Protocol.log("Locator error", error);
- return;
- }
- Collection<?> c = (Collection<?>)args[1];
- if (c != null) {
- for (Object o : c) {
- Map<String,String> m = (Map<String,String>)o;
- String id = m.get(IPeer.ATTR_ID);
- if (peers.get(id) != null) continue;
- IPeer peer = new Peer(channel.getRemotePeer(), m);
- peers.put(id, peer);
- for (LocatorListener l : listeners.toArray(new LocatorListener[listeners.size()])) {
- try {
- l.peerAdded(peer);
- }
- catch (Throwable x) {
- Protocol.log("Unhandled exception in Locator listener", x);
- }
- }
- }
- }
- }
- };
- get_peers_done = true;
- }
- }
-
- public void removeListener(LocatorListener listener) {
- listeners.remove(listener);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/MemoryProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/MemoryProxy.java
deleted file mode 100644
index a82649110..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/MemoryProxy.java
+++ /dev/null
@@ -1,409 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.remote;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Base64;
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IErrorReport;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.services.IMemory;
-
-
-public class MemoryProxy implements IMemory {
-
- private final IChannel channel;
- private final Map<MemoryListener,IChannel.IEventListener> listeners =
- new HashMap<MemoryListener,IChannel.IEventListener>();
-
- private static class Range implements Comparable<Range> {
- int offs;
- int size;
- int stat;
- String msg;
-
- public int compareTo(Range o) {
- if (offs < o.offs) return -1;
- if (offs > o.offs) return +1;
- return 0;
- }
- }
-
- private class MemoryErrorReport extends MemoryError implements ErrorOffset, IErrorReport {
-
- private static final long serialVersionUID = 796525409870265390L;
- private final Map<String,Object> attrs;
- private final Range[] ranges;
-
- @SuppressWarnings("unchecked")
- MemoryErrorReport(String msg, Map<String,Object> attrs, Number addr, Object ranges) {
- super(msg);
- this.attrs = attrs;
- Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)ranges;
- this.ranges = c == null ? null : new Range[c.size()];
- if (c != null) {
- int n = 0;
- BigInteger addr_bi = addr instanceof BigInteger ?
- (BigInteger)addr : new BigInteger(addr.toString());
- for (Map<String,Object> m : c) {
- Range r = new Range();
- Number x = (Number)m.get("addr");
- BigInteger y = x instanceof BigInteger ?
- (BigInteger)x : new BigInteger(x.toString());
- r.offs = addr_bi.subtract(y).intValue();
- r.size = ((Number)m.get("size")).intValue();
- r.stat = ((Number)m.get("stat")).intValue();
- r.msg = Command.toErrorString(m.get("msg"));
- assert r.offs >= 0;
- assert r.size >= 0;
- this.ranges[n++] = r;
- }
- Arrays.sort(this.ranges);
- }
- }
-
- public int getErrorCode() {
- Number n = (Number)attrs.get(ERROR_CODE);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public int getAltCode() {
- Number n = (Number)attrs.get(ERROR_ALT_CODE);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public String getAltOrg() {
- return (String)attrs.get(ERROR_ALT_ORG);
- }
-
- public Map<String, Object> getAttributes() {
- return attrs;
- }
-
- public String getMessage(int offset) {
- if (ranges == null) return null;
- int l = 0;
- int h = ranges.length - 1;
- while (l <= h) {
- int n = (l + h) / 2;
- Range r = ranges[n];
- if (r.offs > offset) {
- h = n - 1;
- }
- else if (offset >= r.offs + r.size) {
- l = n + 1;
- }
- else {
- return r.msg;
- }
- }
- return null;
- }
-
- public int getStatus(int offset) {
- if (ranges == null) return BYTE_UNKNOWN;
- int l = 0;
- int h = ranges.length - 1;
- while (l <= h) {
- int n = (l + h) / 2;
- Range r = ranges[n];
- if (r.offs > offset) {
- h = n - 1;
- }
- else if (offset >= r.offs + r.size) {
- l = n + 1;
- }
- else {
- return r.stat;
- }
- }
- return BYTE_UNKNOWN;
- }
- }
-
- private class MemContext implements MemoryContext {
-
- private final Map<String,Object> props;
-
- MemContext(Map<String,Object> props) {
- this.props = props;
- }
-
- public String getID() {
- return (String)props.get(PROP_ID);
- }
-
- public String getParentID() {
- return (String)props.get(PROP_PARENT_ID);
- }
-
- public int getAddressSize() {
- Number n = (Number)props.get(PROP_ADDRESS_SIZE);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public String getProcessID() {
- return (String)props.get(PROP_PROCESS_ID);
- }
-
- public boolean isBigEndian() {
- Boolean n = (Boolean)props.get(PROP_BIG_ENDIAN);
- if (n == null) return false;
- return n.booleanValue();
- }
-
- @SuppressWarnings("unchecked")
- public Collection<String> getAccessTypes() {
- return (Collection<String>)props.get(PROP_ACCESS_TYPES);
- }
-
- public Number getEndBound() {
- return (Number)props.get(PROP_END_BOUND);
- }
-
- public String getName() {
- return (String)props.get(PROP_NAME);
- }
-
- public Number getStartBound() {
- return (Number)props.get(PROP_START_BOUND);
- }
-
- public Map<String, Object> getProperties() {
- return props;
- }
-
- public IToken fill(final Number addr, int word_size,
- byte[] value, int size, int mode, final DoneMemory done) {
- return new MemoryCommand("fill", new Object[] {
- getID(), addr, word_size, size, mode, value
- } ) {
- public void done(Exception error, Object[] args) {
- MemoryError e = null;
- if (error != null) {
- e = new MemoryError(error.getMessage());
- }
- else {
- assert args.length == 2;
- e = toMemoryError(addr, args[0], args[1]);
- }
- done.doneMemory(token, e);
- }
- }.token;
- }
-
- public IToken get(final Number addr, int word_size,
- final byte[] buf, final int offs, final int size,
- int mode, final DoneMemory done) {
- return new MemoryCommand("get", new Object[] {
- getID(), addr, word_size, size, mode
- } ) {
- public void done(Exception error, Object[] args) {
- MemoryError e = null;
- if (error != null) {
- e = new MemoryError(error.getMessage());
- }
- else {
- assert args.length == 3;
- String str = (String)args[0];
- if (str != null) Base64.toByteArray(buf, offs, size, str.toCharArray());
- e = toMemoryError(addr, args[1], args[2]);
- }
- done.doneMemory(token, e);
- }
- }.token;
- }
-
- public IToken set(final Number addr, int word_size,
- byte[] buf, int offs, int size, int mode, final DoneMemory done) {
- return new MemoryCommand("set", new Object[] {
- getID(), addr, word_size, size, mode, Base64.toBase64(buf, offs, size)
- } ) {
- public void done(Exception error, Object[] args) {
- MemoryError e = null;
- if (error != null) {
- e = new MemoryError(error.getMessage());
- }
- else {
- assert args.length == 2;
- e = toMemoryError(addr, args[0], args[1]);
- }
- done.doneMemory(token, e);
- }
- }.token;
- }
-
- public String toString() {
- return "[Memory Context " + props.toString() + "]";
- }
- }
-
- public MemoryProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public void addListener(final MemoryListener listener) {
- IChannel.IEventListener l = new IChannel.IEventListener() {
-
- public void event(String name, byte[] data) {
- try {
- Object[] args = JSON.parseSequence(data);
- if (name.equals("contextAdded")) {
- assert args.length == 1;
- listener.contextAdded(toContextArray(args[0]));
- }
- else if (name.equals("contextChanged")) {
- assert args.length == 1;
- listener.contextChanged(toContextArray(args[0]));
- }
- else if (name.equals("contextRemoved")) {
- assert args.length == 1;
- listener.contextRemoved(toStringArray(args[0]));
- }
- else if (name.equals("memoryChanged")) {
- assert args.length == 2;
- listener.memoryChanged((String)args[0],
- toAddrArray(args[1]), toSizeArray(args[1]));
- }
- else {
- throw new IOException("Memory service: unknown event: " + name);
- }
- }
- catch (Throwable x) {
- channel.terminate(x);
- }
- }
- };
- channel.addEventListener(this, l);
- listeners.put(listener, l);
- }
-
- public void removeListener(MemoryListener listener) {
- IChannel.IEventListener l = listeners.remove(listener);
- if (l != null) channel.removeEventListener(this, l);
- }
-
- public IToken getContext(String context_id, final DoneGetContext done) {
- return new Command(channel, this, "getContext", new Object[]{ context_id }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- MemContext ctx = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- if (args[1] != null) ctx = new MemContext((Map<String,Object>)args[1]);
- }
- done.doneGetContext(token, error, ctx);
- }
- }.token;
- }
-
- public IToken getChildren(String parent_context_id, final DoneGetChildren done) {
- return new Command(channel, this, "getChildren", new Object[]{ parent_context_id }) {
- @Override
- public void done(Exception error, Object[] args) {
- String[] arr = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- arr = toStringArray(args[1]);
- }
- done.doneGetChildren(token, error, arr);
- }
- }.token;
- }
-
- public String getName() {
- return NAME;
- }
-
- private abstract class MemoryCommand extends Command {
-
- MemoryCommand(String cmd, Object[] args) {
- super(channel, MemoryProxy.this, cmd, args);
- }
-
- @SuppressWarnings("unchecked")
- MemoryError toMemoryError(Number addr, Object data, Object ranges) {
- if (data == null) return null;
- Map<String,Object> map = (Map<String,Object>)data;
- Integer code = (Integer)map.get(IErrorReport.ERROR_CODE);
- String cmd = getCommandString();
- if (cmd.length() > 72) cmd = cmd.substring(0, 72) + "...";
- MemoryError e = new MemoryErrorReport(
- "TCF command exception:" +
- "\nCommand: " + cmd +
- "\nException: " + toErrorString(data) +
- "\nError code: " + code,
- map, addr, ranges);
- Object caused_by = map.get(IErrorReport.ERROR_CAUSED_BY);
- if (caused_by != null) e.initCause(toError(caused_by, false));
- return e;
- }
- }
-
- @SuppressWarnings("unchecked")
- private MemoryContext[] toContextArray(Object o) {
- Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o;
- if (c == null) return new MemoryContext[0];
- int n = 0;
- MemoryContext[] ctx = new MemoryContext[c.size()];
- for (Iterator<Map<String,Object>> i = c.iterator(); i.hasNext();) {
- ctx[n++] = new MemContext(i.next());
- }
- return ctx;
- }
-
- @SuppressWarnings("unchecked")
- private long[] toSizeArray(Object o) {
- Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o;
- if (c == null) return null;
- long[] a = new long[c.size()];
- int n = 0;
- for (Map<String,Object> m : c) {
- Number sz = (Number)m.get("size");
- a[n++] = sz == null ? 0 : sz.longValue();
- }
- return a;
- }
-
- @SuppressWarnings("unchecked")
- private Number[] toAddrArray(Object o) {
- Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o;
- if (c == null) return null;
- Number[] a = new Number[c.size()];
- int n = 0;
- for (Map<String,Object> m : c) {
- a[n++] = (Number)m.get("addr");
- }
- return a;
- }
-
- @SuppressWarnings("unchecked")
- private String[] toStringArray(Object o) {
- if (o == null) return null;
- Collection<String> c = (Collection<String>)o;
- return (String[])c.toArray(new String[c.size()]);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ProcessesProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ProcessesProxy.java
deleted file mode 100644
index b75c48c71..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ProcessesProxy.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.remote;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.services.IProcesses;
-
-
-public class ProcessesProxy implements IProcesses {
-
- private final IChannel channel;
- private final Map<ProcessesListener,IChannel.IEventListener> listeners =
- new HashMap<ProcessesListener,IChannel.IEventListener>();
-
- private class ProcessContext implements IProcesses.ProcessContext {
-
- private final Map<String,Object> props;
-
- ProcessContext(Map<String,Object> props) {
- this.props = props;
- }
-
- public String getID() {
- return (String)props.get(PROP_ID);
- }
-
- public String getParentID() {
- return (String)props.get(PROP_PARENTID);
- }
-
- public boolean canTerminate() {
- Boolean b = (Boolean)props.get(PROP_CAN_TERMINATE);
- return b != null && b.booleanValue();
- }
-
- public String getName() {
- return (String)props.get(PROP_NAME);
- }
-
- public boolean isAttached() {
- Boolean b = (Boolean)props.get(PROP_ATTACHED);
- return b != null && b.booleanValue();
- }
-
- public IToken attach(final DoneCommand done) {
- return new Command(channel, ProcessesProxy.this,
- "attach", new Object[]{ getID() }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCommand(token, error);
- }
- }.token;
- }
-
- public IToken detach(final DoneCommand done) {
- return new Command(channel, ProcessesProxy.this,
- "detach", new Object[]{ getID() }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCommand(token, error);
- }
- }.token;
- }
-
- public IToken terminate(final DoneCommand done) {
- return new Command(channel, ProcessesProxy.this,
- "terminate", new Object[]{ getID() }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCommand(token, error);
- }
- }.token;
- }
-
- public Map<String, Object> getProperties() {
- return props;
- }
-
- public String toString() {
- return "[Processes Context " + props.toString() + "]";
- }
- }
-
- public ProcessesProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public String getName() {
- return NAME;
- }
-
- public void addListener(final ProcessesListener listener) {
- IChannel.IEventListener l = new IChannel.IEventListener() {
-
- public void event(String name, byte[] data) {
- try {
- Object[] args = JSON.parseSequence(data);
- if (name.equals("exited")) {
- assert args.length == 2;
- listener.exited((String)args[0], ((Number)args[1]).intValue());
- }
- else {
- throw new IOException("Processes service: unknown event: " + name);
- }
- }
- catch (Throwable x) {
- channel.terminate(x);
- }
- }
- };
- channel.addEventListener(this, l);
- listeners.put(listener, l);
- }
-
- public void removeListener(ProcessesListener listener) {
- IChannel.IEventListener l = listeners.remove(listener);
- if (l != null) channel.removeEventListener(this, l);
- }
-
- public IToken getChildren(String parent_context_id, boolean attached_only, final DoneGetChildren done) {
- return new Command(channel, this,
- "getChildren", new Object[]{ parent_context_id, attached_only }) {
- @Override
- public void done(Exception error, Object[] args) {
- String[] ids = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- ids = toStringArray(args[1]);
- }
- done.doneGetChildren(token, error, ids);
- }
- }.token;
- }
-
- public IToken getContext(String id, final DoneGetContext done) {
- return new Command(channel, this,
- "getContext", new Object[]{ id }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- ProcessContext ctx = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- if (args[1] != null) ctx = new ProcessContext((Map<String, Object>)args[1]);
- }
- done.doneGetContext(token, error, ctx);
- }
- }.token;
- }
-
- public IToken getEnvironment(final DoneGetEnvironment done) {
- return new Command(channel, this, "getEnvironment", null) {
- @Override
- public void done(Exception error, Object[] args) {
- Map<String,String> env = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- env = toEnvMap(args[1]);
- }
- done.doneGetEnvironment(token, error, env);
- }
- }.token;
- }
-
- public IToken start(String directory, String file,
- String[] command_line, Map<String,String> environment,
- boolean attach, final DoneStart done) {
- return new Command(channel, this,
- "start", new Object[]{ directory, file, command_line,
- toEnvStringArray(environment), attach }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- ProcessContext ctx = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- if (args[1] != null) ctx = new ProcessContext((Map<String, Object>)args[1]);
- }
- done.doneStart(token, error, ctx);
- }
- }.token;
- }
-
- public IToken getSignalList(String context_id, final DoneGetSignalList done) {
- return new Command(channel, ProcessesProxy.this,
- "getSignalList", new Object[]{ context_id }) {
- @Override
- public void done(Exception error, Object[] args) {
- Collection<Map<String,Object>> list = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- list = toSignalList(args[1]);
- }
- done.doneGetSignalList(token, error, list);
- }
- }.token;
- }
-
- public IToken getSignalMask(String context_id, final DoneGetSignalMask done) {
- return new Command(channel, ProcessesProxy.this,
- "getSignalMask", new Object[]{ context_id }) {
- @Override
- public void done(Exception error, Object[] args) {
- int dont_stop = 0;
- int dont_pass = 0;
- int pending = 0;
- if (error == null) {
- assert args.length == 4;
- error = toError(args[0]);
- if (args[1] != null) dont_stop = ((Number)args[1]).intValue();
- if (args[2] != null) dont_pass = ((Number)args[2]).intValue();
- if (args[3] != null) pending = ((Number)args[3]).intValue();
- }
- done.doneGetSignalMask(token, error, dont_stop, dont_pass, pending);
- }
- }.token;
- }
-
- public IToken setSignalMask(String context_id, int dont_stop, int dont_pass, final DoneCommand done) {
- return new Command(channel, ProcessesProxy.this,
- "setSignalMask", new Object[]{ context_id, dont_stop, dont_pass }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCommand(token, error);
- }
- }.token;
- }
-
- public IToken signal(String context_id, long signal, final DoneCommand done) {
- return new Command(channel, ProcessesProxy.this,
- "signal", new Object[]{ context_id, signal }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCommand(token, error);
- }
- }.token;
- }
-
- @SuppressWarnings("unchecked")
- private static String[] toStringArray(Object o) {
- if (o == null) return null;
- Collection<String> c = (Collection<String>)o;
- return (String[])c.toArray(new String[c.size()]);
- }
-
- private static String[] toEnvStringArray(Map<String,String> m) {
- if (m == null) return new String[0];
- int n = 0;
- String[] arr = new String[m.size()];
- for (String s : m.keySet()) {
- arr[n++] = s + "=" + m.get(s);
- }
- return arr;
- }
-
- @SuppressWarnings("unchecked")
- private static Map<String,String> toEnvMap(Object o) {
- Map<String,String> m = new HashMap<String,String>();
- if (o == null) return m;
- Collection<String> c = (Collection<String>)o;
- for (String s : c) {
- int i = s.indexOf('=');
- if (i >= 0) m.put(s.substring(0, i), s.substring(i + 1));
- else m.put(s, "");
- }
- return m;
- }
-
- @SuppressWarnings("unchecked")
- private static Collection<Map<String,Object>> toSignalList(Object o) {
- if (o == null) return null;
- return (Collection<Map<String,Object>>)o;
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RegistersProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RegistersProxy.java
deleted file mode 100644
index bdeb91af3..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RegistersProxy.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.remote;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Base64;
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.services.IRegisters;
-
-
-public class RegistersProxy implements IRegisters {
-
- private final IChannel channel;
- private final Map<RegistersListener,IChannel.IEventListener> listeners =
- new HashMap<RegistersListener,IChannel.IEventListener>();
-
- private class Context implements RegistersContext {
-
- private final Map<String,Object> props;
-
- Context(Map<String,Object> props) {
- this.props = props;
- }
-
- public int[] getBitNumbers() {
- return toIntArray(props.get(PROP_BITS));
- }
-
- public String getDescription() {
- return (String)props.get(PROP_DESCRIPTION);
- }
-
- public int getFirstBitNumber() {
- Number n = (Number)props.get(PROP_FIST_BIT);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public String getID() {
- return (String)props.get(PROP_ID);
- }
-
- public String getName() {
- return (String)props.get(PROP_NAME);
- }
-
- public NamedValue[] getNamedValues() {
- return toValuesArray(props.get(PROP_VALUES));
- }
-
- public String getParentID() {
- return (String)props.get(PROP_PARENT_ID);
- }
-
- public int getSize() {
- Number n = (Number)props.get(PROP_SIZE);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public Map<String, Object> getProperties() {
- return props;
- }
-
- public boolean hasSideEffects() {
- Boolean n = (Boolean)props.get(PROP_SIDE_EFFECTS);
- if (n == null) return false;
- return n.booleanValue();
- }
-
- public boolean isBigEndian() {
- Boolean n = (Boolean)props.get(PROP_BIG_ENDIAN);
- if (n == null) return false;
- return n.booleanValue();
- }
-
- public boolean isFloat() {
- Boolean n = (Boolean)props.get(PROP_FLOAT);
- if (n == null) return false;
- return n.booleanValue();
- }
-
- public boolean isLeftToRight() {
- Boolean n = (Boolean)props.get(PROP_LEFT_TO_RIGHT);
- if (n == null) return false;
- return n.booleanValue();
- }
-
- public boolean isReadOnce() {
- Boolean n = (Boolean)props.get(PROP_READ_ONCE);
- if (n == null) return false;
- return n.booleanValue();
- }
-
- public boolean isReadable() {
- Boolean n = (Boolean)props.get(PROP_READBLE);
- if (n == null) return false;
- return n.booleanValue();
- }
-
- public boolean isVolatile() {
- Boolean n = (Boolean)props.get(PROP_VOLATILE);
- if (n == null) return false;
- return n.booleanValue();
- }
-
- public boolean isWriteOnce() {
- Boolean n = (Boolean)props.get(PROP_WRITE_ONCE);
- if (n == null) return false;
- return n.booleanValue();
- }
-
- public boolean isWriteable() {
- Boolean n = (Boolean)props.get(PROP_WRITEABLE);
- if (n == null) return false;
- return n.booleanValue();
- }
-
- @SuppressWarnings("unchecked")
- public Collection<String> canSearch() {
- return (Collection<String>)props.get(PROP_CAN_SEARCH);
- }
-
- public Number getMemoryAddress() {
- return (Number)props.get(PROP_MEMORY_ADDRESS);
- }
-
- public String getMemoryContext() {
- return (String)props.get(PROP_MEMORY_CONTEXT);
- }
-
- public String getProcessID() {
- return (String)props.get(PROP_PROCESS_ID);
- }
-
- public String getRole() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public IToken get(final DoneGet done) {
- return new Command(channel, RegistersProxy.this, "get",
- new Object[]{ getID() }) {
- @Override
- public void done(Exception error, Object[] args) {
- byte[] val = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- String str = (String)args[1];
- if (str != null) val = Base64.toByteArray(str.toCharArray());
- }
- done.doneGet(token, error, val);
- }
- }.token;
- }
-
- public IToken set(byte[] value, final DoneSet done) {
- return new Command(channel, RegistersProxy.this, "set",
- new Object[]{ getID(), Base64.toBase64(value, 0, value.length) }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneSet(token, error);
- }
- }.token;
- }
-
- public IToken search(Map<String,Object> filter, final DoneSearch done) {
- return new Command(channel, RegistersProxy.this, "search",
- new Object[]{ getID(), filter }) {
- @Override
- public void done(Exception error, Object[] args) {
- String[][] paths = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- paths = toPathArray(args[1]);
- }
- done.doneSearch(token, error, paths);
- }
- }.token;
- }
-
- public String toString() {
- return "[Registers Context " + props.toString() + "]";
- }
- }
-
- public RegistersProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public String getName() {
- return NAME;
- }
-
- public IToken getChildren(String parent_context_id, final DoneGetChildren done) {
- return new Command(channel, this, "getChildren", new Object[]{ parent_context_id }) {
- @Override
- public void done(Exception error, Object[] args) {
- String[] arr = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- arr = toStringArray(args[1]);
- }
- done.doneGetChildren(token, error, arr);
- }
- }.token;
- }
-
- public IToken getContext(String id, final DoneGetContext done) {
- return new Command(channel, this, "getContext", new Object[]{ id }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- Context ctx = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- if (args[1] != null) ctx = new Context((Map<String,Object>)args[1]);
- }
- done.doneGetContext(token, error, ctx);
- }
- }.token;
- }
-
- public IToken getm(Location[] locs, final DoneGet done) {
- return new Command(channel, this, "getm", new Object[]{ locs }) {
- @Override
- public void done(Exception error, Object[] args) {
- byte[] val = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- String str = (String)args[1];
- if (str != null) val = Base64.toByteArray(str.toCharArray());
- }
- done.doneGet(token, error, val);
- }
- }.token;
- }
-
- public IToken setm(Location[] locs, byte[] value, final DoneSet done) {
- return new Command(channel, this, "setm",
- new Object[]{ locs, Base64.toBase64(value, 0, value.length) }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneSet(token, error);
- }
- }.token;
- }
-
- public void addListener(final RegistersListener listener) {
- IChannel.IEventListener l = new IChannel.IEventListener() {
-
- public void event(String name, byte[] data) {
- try {
- Object[] args = JSON.parseSequence(data);
- if (name.equals("contextChanged")) {
- listener.contextChanged();
- }
- else if (name.equals("registerChanged")) {
- assert args.length == 1;
- listener.registerChanged((String)args[0]);
- }
- else {
- throw new IOException("Registers service: unknown event: " + name);
- }
- }
- catch (Throwable x) {
- channel.terminate(x);
- }
- }
- };
- channel.addEventListener(this, l);
- listeners.put(listener, l);
- }
-
- public void removeListener(RegistersListener listener) {
- IChannel.IEventListener l = listeners.remove(listener);
- if (l != null) channel.removeEventListener(this, l);
- }
-
- @SuppressWarnings("unchecked")
- private String[] toStringArray(Object o) {
- if (o == null) return null;
- Collection<String> c = (Collection<String>)o;
- return (String[])c.toArray(new String[c.size()]);
- }
-
- @SuppressWarnings("unchecked")
- private int[] toIntArray(Object o) {
- if (o == null) return null;
- Collection<Number> c = (Collection<Number>)o;
- int i = 0;
- int[] arr = new int[c.size()];
- for (Number n : c) arr[i++] = n.intValue();
- return arr;
- }
-
- @SuppressWarnings("unchecked")
- private String[][] toPathArray(Object o) {
- if (o == null) return null;
- Collection<Collection<String>> c = (Collection<Collection<String>>)o;
- int i = 0;
- String[][] r = new String[c.size()][];
- for (Collection<String> p : c) {
- r[i++] = (String[])p.toArray(new String[p.size()]);
- }
- return r;
- }
-
- private static class NamedValueInfo implements NamedValue {
-
- private final String desc;
- private final String name;
- private final byte[] value;
-
- NamedValueInfo(Map<String,Object> m) {
- desc = (String)m.get("Description");
- name = (String)m.get("Name");
- String str = (String)m.get("Value");
- if (str == null) value = null;
- else value = Base64.toByteArray(str.toCharArray());
- }
-
- public String getDescription() {
- return desc;
- }
-
- public String getName() {
- return name;
- }
-
- public byte[] getValue() {
- return value;
- }
- }
-
- @SuppressWarnings("unchecked")
- private NamedValue[] toValuesArray(Object o) {
- Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o;
- if (c == null) return null;
- int i = 0;
- NamedValue[] arr = new NamedValue[c.size()];
- for (final Map<String,Object> m : c) {
- arr[i++] = new NamedValueInfo(m);
- }
- return arr;
- }
-
- static {
- JSON.addObjectWriter(Location.class, new JSON.ObjectWriter() {
- public void write(Object o) throws IOException {
- Location l = (Location)o;
- JSON.write('[');
- JSON.writeObject(l.id);
- JSON.write(',');
- JSON.writeUInt(l.offs);
- JSON.write(',');
- JSON.writeUInt(l.size);
- JSON.write(']');
- }
- });
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RunControlProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RunControlProxy.java
deleted file mode 100644
index df1edf285..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/RunControlProxy.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.remote;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.services.IRunControl;
-
-
-public class RunControlProxy implements IRunControl {
-
- private final IChannel channel;
- private final Map<RunControlListener,IChannel.IEventListener> listeners =
- new HashMap<RunControlListener,IChannel.IEventListener>();
-
- private class RunContext implements IRunControl.RunControlContext {
-
- private final Map<String, Object> props;
-
- RunContext(Map<String, Object> props) {
- this.props = props;
- }
-
- public Map<String, Object> getProperties() {
- return props;
- }
-
- public String getID() {
- return (String)props.get(PROP_ID);
- }
-
- public String getParentID() {
- return (String)props.get(PROP_PARENT_ID);
- }
-
- public boolean isContainer() {
- Boolean b = (Boolean)props.get(PROP_IS_CONTAINER);
- return b != null && b.booleanValue();
- }
-
- public boolean hasState() {
- Boolean b = (Boolean)props.get(PROP_HAS_STATE);
- return b != null && b.booleanValue();
- }
-
- public boolean canResume(int mode) {
- if (props.containsKey(PROP_CAN_RESUME)) {
- int b = ((Number)props.get(PROP_CAN_RESUME)).intValue();
- return (b & (1 << mode)) != 0;
- }
- return false;
- }
-
- public boolean canCount(int mode) {
- if (props.containsKey(PROP_CAN_COUNT)) {
- int b = ((Number)props.get(PROP_CAN_COUNT)).intValue();
- return (b & (1 << mode)) != 0;
- }
- return false;
- }
-
- public boolean canSuspend() {
- Boolean b = (Boolean)props.get(PROP_CAN_SUSPEND);
- return b != null && b.booleanValue();
- }
-
- public boolean canTerminate() {
- Boolean b = (Boolean)props.get(PROP_CAN_TERMINATE);
- return b != null && b.booleanValue();
- }
-
- public IToken getState(final DoneGetState done) {
- return new Command(channel, RunControlProxy.this, "getState", new Object[]{ getID() }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- boolean susp = false;
- String pc = null;
- String reason = null;
- Map<String,Object> map = null;
- if (error == null) {
- assert args.length == 5;
- error = toError(args[0]);
- susp = ((Boolean)args[1]).booleanValue();
- if (args[2] != null) pc = ((Number)args[2]).toString();
- reason = (String)args[3];
- map = (Map<String,Object>)args[4];
- }
- done.doneGetState(token, error, susp, pc, reason, map);
- }
- }.token;
- }
-
- public IToken resume(int mode, int count, DoneCommand done) {
- return command("resume", new Object[]{ getID(), mode, count }, done);
- }
-
- public IToken suspend(DoneCommand done) {
- return command("suspend", new Object[]{ getID() }, done);
- }
-
- public IToken terminate(DoneCommand done) {
- return command("terminate", new Object[]{ getID() }, done);
- }
-
- private IToken command(String cmd, Object[] args, final DoneCommand done) {
- return new Command(channel, RunControlProxy.this, cmd, args) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneCommand(token, error);
- }
- }.token;
- }
-
- public String toString() {
- return "[Run Control Context " + props.toString() + "]";
- }
- }
-
- public RunControlProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public String getName() {
- return NAME;
- }
-
- public void addListener(final RunControlListener listener) {
- IChannel.IEventListener l = new IChannel.IEventListener() {
-
- @SuppressWarnings("unchecked")
- public void event(String name, byte[] data) {
- try {
- Object[] args = JSON.parseSequence(data);
- if (name.equals("contextSuspended")) {
- assert args.length == 4;
- listener.contextSuspended(
- (String)args[0],
- args[1] == null ? null : ((Number)args[1]).toString(),
- (String)args[2], (Map<String,Object>)args[3]);
- }
- else if (name.equals("contextResumed")) {
- assert args.length == 1;
- listener.contextResumed((String)args[0]);
- }
- else if (name.equals("contextAdded")) {
- assert args.length == 1;
- listener.contextAdded(toContextArray(args[0]));
- }
- else if (name.equals("contextChanged")) {
- assert args.length == 1;
- listener.contextChanged(toContextArray(args[0]));
- }
- else if (name.equals("contextRemoved")) {
- assert args.length == 1;
- listener.contextRemoved(toStringArray(args[0]));
- }
- else if (name.equals("contextException")) {
- assert args.length == 2;
- listener.contextException((String)args[0], (String)args[1]);
- }
- else if (name.equals("containerSuspended")) {
- assert args.length == 5;
- listener.containerSuspended(
- (String)args[0],
- args[1] == null ? null : ((Number)args[1]).toString(),
- (String)args[2], (Map)args[3],
- toStringArray(args[4]));
- }
- else if (name.equals("containerResumed")) {
- assert args.length == 1;
- listener.containerResumed(toStringArray(args[0]));
- }
- else {
- throw new IOException("RunControl service: unknown event: " + name);
- }
- }
- catch (Throwable x) {
- channel.terminate(x);
- }
- }
- };
- channel.addEventListener(this, l);
- listeners.put(listener, l);
- }
-
- public void removeListener(RunControlListener listener) {
- IChannel.IEventListener l = listeners.remove(listener);
- if (l != null) channel.removeEventListener(this, l);
- }
-
- public IToken getContext(String context_id, final DoneGetContext done) {
- return new Command(channel, this, "getContext", new Object[]{ context_id }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- RunControlContext ctx = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- if (args[1] != null) ctx = new RunContext((Map<String, Object>)args[1]);
- }
- done.doneGetContext(token, error, ctx);
- }
- }.token;
- }
-
- public IToken getChildren(String parent_context_id, final DoneGetChildren done) {
- return new Command(channel, this, "getChildren", new Object[]{ parent_context_id }) {
- @Override
- public void done(Exception error, Object[] args) {
- String[] arr = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- arr = toStringArray(args[1]);
- }
- done.doneGetChildren(token, error, arr);
- }
- }.token;
- }
-
- @SuppressWarnings("unchecked")
- private RunControlContext[] toContextArray(Object o) {
- if (o == null) return null;
- Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o;
- int n = 0;
- RunControlContext[] ctx = new RunControlContext[c.size()];
- for (Map<String, Object> m : c) ctx[n++] = new RunContext(m);
- return ctx;
- }
-
- @SuppressWarnings("unchecked")
- private String[] toStringArray(Object o) {
- if (o == null) return null;
- Collection<String> c = (Collection<String>)o;
- return (String[])c.toArray(new String[c.size()]);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/StackTraceProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/StackTraceProxy.java
deleted file mode 100644
index 59b57c014..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/StackTraceProxy.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.remote;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.services.IStackTrace;
-
-
-public class StackTraceProxy implements IStackTrace {
-
- private final IChannel channel;
-
- private class Context implements StackTraceContext {
-
- private final Map<String,Object> props;
-
- Context(Map<String,Object> props) {
- if (props == null) props = new HashMap<String,Object>();
- this.props = props;
- }
-
- public Number getArgumentsAddress() {
- return (Number)props.get(PROP_ARGUMENTS_ADDRESS);
- }
-
- public int getArgumentsCount() {
- Number n = (Number)props.get(PROP_ARGUMENTS_COUNT);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public Number getFrameAddress() {
- return (Number)props.get(PROP_FRAME_ADDRESS);
- }
-
- public String getID() {
- return (String)props.get(PROP_ID);
- }
-
- public String getName() {
- return (String)props.get(PROP_NAME);
- }
-
- public String getParentID() {
- return (String)props.get(PROP_PARENT_ID);
- }
-
- public Number getReturnAddress() {
- return (Number)props.get(PROP_RETURN_ADDRESS);
- }
-
- public Number getInstructionAddress() {
- return (Number)props.get(PROP_INSTRUCTION_ADDRESS);
- }
-
- public Map<String, Object> getProperties() {
- return props;
- }
- }
-
- public StackTraceProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public IToken getChildren(String parent_context_id, final DoneGetChildren done) {
- return new Command(channel, this, "getChildren", new Object[]{ parent_context_id }) {
- @Override
- public void done(Exception error, Object[] args) {
- String[] arr = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- arr = toStringArray(args[1]);
- }
- done.doneGetChildren(token, error, arr);
- }
- }.token;
- }
-
- public IToken getContext(String[] id, final DoneGetContext done) {
- return new Command(channel, this, "getContext", new Object[]{ id }) {
- @Override
- public void done(Exception error, Object[] args) {
- StackTraceContext[] arr = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[1]);
- arr = toContextArray(args[0]);
- }
- done.doneGetContext(token, error, arr);
- }
- }.token;
- }
-
- public String getName() {
- return NAME;
- }
-
- @SuppressWarnings("unchecked")
- private StackTraceContext[] toContextArray(Object o) {
- if (o == null) return null;
- Collection<Map<String,Object>> c = (Collection<Map<String,Object>>)o;
- int n = 0;
- StackTraceContext[] ctx = new StackTraceContext[c.size()];
- for (Map<String,Object> m : c) ctx[n++] = new Context(m);
- return ctx;
- }
-
- @SuppressWarnings("unchecked")
- private String[] toStringArray(Object o) {
- if (o == null) return null;
- Collection<String> c = (Collection<String>)o;
- return (String[])c.toArray(new String[c.size()]);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/StreamsProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/StreamsProxy.java
deleted file mode 100644
index 4dfd93424..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/StreamsProxy.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.tm.internal.tcf.services.remote;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Base64;
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.services.IStreams;
-
-public class StreamsProxy implements IStreams {
-
- private final IChannel channel;
- private final Map<StreamsListener,IChannel.IEventListener> listeners =
- new HashMap<StreamsListener,IChannel.IEventListener>();
-
- public StreamsProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public IToken disconnect(String stream_id, final DoneDisconnect done) {
- return new Command(channel, this, "disconnect", new Object[]{ stream_id }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneDisconnect(token, error);
- }
- }.token;
- }
-
- public IToken eos(String stream_id, final DoneEOS done) {
- return new Command(channel, this, "eos", new Object[]{ stream_id }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneEOS(token, error);
- }
- }.token;
- }
-
- public IToken read(String stream_id, int size, final DoneRead done) {
- return new Command(channel, this, "read", new Object[]{ stream_id, size }) {
- @Override
- public void done(Exception error, Object[] args) {
- int lost_size = 0;
- byte data[] = null;
- boolean eos = false;
- if (error == null) {
- assert args.length == 4;
- String str = (String)args[0];
- error = toError(args[1]);
- lost_size = ((Number)args[2]).intValue();
- eos = ((Boolean)args[3]).booleanValue();
- if (str != null) data = Base64.toByteArray(str.toCharArray());
- }
- done.doneRead(token, error, lost_size, data, eos);
- }
- }.token;
- }
-
- public IToken subscribe(String stream_type, final StreamsListener listener, final DoneSubscribe done) {
- return new Command(channel, this, "subscribe", new Object[]{ stream_type }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- if (error == null) {
- IChannel.IEventListener l = new IChannel.IEventListener() {
-
- public void event(String name, byte[] data) {
- try {
- Object[] args = JSON.parseSequence(data);
- if (name.equals("created")) {
- assert args.length == 2;
- listener.created((String)args[0], (String)args[1]);
- }
- else if (name.equals("disposed")) {
- assert args.length == 2;
- listener.disposed((String)args[0], (String)args[1]);
- }
- else {
- throw new IOException("Streams service: unknown event: " + name);
- }
- }
- catch (Throwable x) {
- channel.terminate(x);
- }
- }
- };
- listeners.put(listener, l);
- channel.addEventListener(StreamsProxy.this, l);
- }
- done.doneSubscribe(token, error);
- }
- }.token;
- }
-
- public IToken unsubscribe(String stream_type, final StreamsListener listener, final DoneUnsubscribe done) {
- return new Command(channel, this, "unsubscribe", new Object[]{ stream_type }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- if (error == null) {
- IChannel.IEventListener l = listeners.remove(listener);
- if (l != null) channel.removeEventListener(StreamsProxy.this, l);
- }
- done.doneUnsubscribe(token, error);
- }
- }.token;
- }
-
- public IToken write(String stream_id, byte[] buf, int offset, int size, final DoneWrite done) {
- return new Command(channel, this, "write", new Object[]{ stream_id, size, Base64.toBase64(buf, offset, size) }) {
- @Override
- public void done(Exception error, Object[] args) {
- if (error == null) {
- assert args.length == 1;
- error = toError(args[0]);
- }
- done.doneWrite(token, error);
- }
- }.token;
- }
-
- public String getName() {
- return NAME;
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/SymbolsProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/SymbolsProxy.java
deleted file mode 100644
index b211887ac..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/SymbolsProxy.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.eclipse.tm.internal.tcf.services.remote;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Base64;
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.services.ISymbols;
-
-public class SymbolsProxy implements ISymbols {
-
- private final IChannel channel;
-
- private class Context implements Symbol {
-
- private final byte[] value;
- private final Map<String,Object> props;
-
- Context(Map<String,Object> props) {
- this.props = props;
- String s = (String)props.get(PROP_VALUE);
- if (s == null) {
- value = null;
- }
- else {
- value = Base64.toByteArray(s.toCharArray());
- }
- }
-
- public Number getAddress() {
- return (Number)props.get(PROP_ADDRESS);
- }
-
- public String getBaseTypeID() {
- return (String)props.get(PROP_BASE_TYPE_ID);
- }
-
- public String getExeContextID() {
- return (String)props.get(PROP_EXE_ID);
- }
-
- public String getID() {
- return (String)props.get(PROP_ID);
- }
-
- public String getIndexTypeID() {
- return (String)props.get(PROP_INDEX_TYPE_ID);
- }
-
- public int getLength() {
- Number n = (Number)props.get(PROP_LENGTH);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public String getName() {
- return (String)props.get(PROP_NAME);
- }
-
- public int getOffset() {
- Number n = (Number)props.get(PROP_OFFSET);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public Map<String,Object> getProperties() {
- return props;
- }
-
- public int getSize() {
- Number n = (Number)props.get(PROP_SIZE);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public SymbolClass getSymbolClass() {
- Number n = (Number)props.get(PROP_SYMBOL_CLASS);
- if (n != null) {
- switch (n.intValue()) {
- case 1: return SymbolClass.value;
- case 2: return SymbolClass.reference;
- case 3: return SymbolClass.function;
- case 4: return SymbolClass.type;
- }
- }
- return SymbolClass.unknown;
- }
-
- public TypeClass getTypeClass() {
- Number n = (Number)props.get(PROP_TYPE_CLASS);
- if (n != null) {
- switch (n.intValue()) {
- case 1: return TypeClass.cardinal;
- case 2: return TypeClass.integer;
- case 3: return TypeClass.real;
- case 4: return TypeClass.pointer;
- case 5: return TypeClass.array;
- case 6: return TypeClass.composite;
- case 7: return TypeClass.enumeration;
- case 8: return TypeClass.function;
- }
- }
- return TypeClass.unknown;
- }
-
- public String getTypeID() {
- return (String)props.get(PROP_TYPE_ID);
- }
-
- public byte[] getValue() {
- return value;
- }
- }
-
- public SymbolsProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public String getName() {
- return NAME;
- }
-
- public IToken getContext(String id, final DoneGetContext done) {
- return new Command(channel, this, "getContext", new Object[]{ id }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- Context ctx = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- if (args[1] != null) ctx = new Context((Map<String,Object>)args[1]);
- }
- done.doneGetContext(token, error, ctx);
- }
- }.token;
- }
-
- public IToken getChildren(String parent_context_id, final DoneGetChildren done) {
- return new Command(channel, this, "getChildren", new Object[]{ parent_context_id }) {
- @Override
- public void done(Exception error, Object[] args) {
- String[] lst = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- lst = toStringArray(args[1]);
- }
- done.doneGetChildren(token, error, lst);
- }
- }.token;
- }
-
- @SuppressWarnings("unchecked")
- private String[] toStringArray(Object o) {
- if (o == null) return null;
- Collection<String> c = (Collection<String>)o;
- return (String[])c.toArray(new String[c.size()]);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/SysMonitorProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/SysMonitorProxy.java
deleted file mode 100644
index 75a17d5d5..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/SysMonitorProxy.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.internal.tcf.services.remote;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.core.Command;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.services.ISysMonitor;
-
-
-public class SysMonitorProxy implements ISysMonitor {
-
- private final IChannel channel;
-
- private class SysMonitorContext implements ISysMonitor.SysMonitorContext {
-
- private final Map<String, Object> props;
-
- SysMonitorContext(Map<String, Object> props) {
- this.props = props;
- }
-
- public String getID() {
- return (String)props.get(PROP_ID);
- }
-
- public String getCurrentWorkingDirectory() {
- return (String)props.get(PROP_CWD);
- }
-
- public String getFile() {
- return (String)props.get(PROP_FILE);
- }
-
- public String getParentID() {
- return (String)props.get(PROP_PARENTID);
- }
-
- public String getRoot() {
- return (String)props.get(PROP_ROOT);
- }
-
- public String getGroupName() {
- return (String)props.get(PROP_GROUPNAME);
- }
-
- public long getPGRP() {
- if (!props.containsKey(PROP_PGRP)) return -1;
- return ((Number)props.get(PROP_PGRP)).longValue();
- }
-
- public long getPID() {
- if (!props.containsKey(PROP_PID)) return -1;
- return ((Number)props.get(PROP_PID)).longValue();
- }
-
- public long getPPID() {
- if (!props.containsKey(PROP_PPID)) return -1;
- return ((Number)props.get(PROP_PPID)).longValue();
- }
-
- public long getRSS() {
- if (!props.containsKey(PROP_RSS)) return -1;
- return ((Number)props.get(PROP_RSS)).longValue();
- }
-
- public String getState() {
- return (String)props.get(PROP_STATE);
- }
-
- public long getTGID() {
- if (!props.containsKey(PROP_TGID)) return -1;
- return ((Number)props.get(PROP_TGID)).longValue();
- }
-
- public long getTracerPID() {
- if (!props.containsKey(PROP_TRACERPID)) return -1;
- return ((Number)props.get(PROP_TRACERPID)).longValue();
- }
-
- public long getUGID() {
- if (!props.containsKey(PROP_UGID)) return -1;
- return ((Number)props.get(PROP_UGID)).longValue();
- }
-
- public long getUID() {
- if (!props.containsKey(PROP_UID)) return -1;
- return ((Number)props.get(PROP_UID)).longValue();
- }
-
- public String getUserName() {
- return (String)props.get(PROP_USERNAME);
- }
-
- public long getVSize() {
- if (!props.containsKey(PROP_VSIZE)) return -1;
- return ((Number)props.get(PROP_VSIZE)).longValue();
- }
-
- public long getPSize() {
- if (!props.containsKey(PROP_PSIZE)) return -1;
- return ((Number)props.get(PROP_PSIZE)).longValue();
- }
-
- public Map<String, Object> getProperties() {
- return props;
- }
-
- public String toString() {
- return "[Sys Monitor Context " + props.toString() + "]";
- }
- }
-
- public SysMonitorProxy(IChannel channel) {
- this.channel = channel;
- }
-
- public String getName() {
- return NAME;
- }
-
- public IToken getChildren(String parent_context_id, final DoneGetChildren done) {
- return new Command(channel, this, "getChildren", new Object[]{ parent_context_id }) {
- @Override
- public void done(Exception error, Object[] args) {
- String[] arr = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- arr = toStringArray(args[1]);
- }
- done.doneGetChildren(token, error, arr);
- }
- }.token;
- }
-
- public IToken getContext(String id, final DoneGetContext done) {
- return new Command(channel, this, "getContext", new Object[]{ id }) {
- @SuppressWarnings("unchecked")
- @Override
- public void done(Exception error, Object[] args) {
- SysMonitorContext ctx = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- if (args[1] != null) ctx = new SysMonitorContext((Map<String, Object>)args[1]);
- }
- done.doneGetContext(token, error, ctx);
- }
- }.token;
- }
-
- public IToken getCommandLine(String id, final DoneGetCommandLine done) {
- return new Command(channel, this, "getCommandLine", new Object[]{ id }) {
- @Override
- public void done(Exception error, Object[] args) {
- String[] arr = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- arr = toStringArray(args[1]);
- }
- done.doneGetCommandLine(token, error, arr);
- }
- }.token;
- }
-
- public IToken getEnvironment(String id, final DoneGetEnvironment done) {
- return new Command(channel, this, "getEnvironment", new Object[]{ id }) {
- @Override
- public void done(Exception error, Object[] args) {
- String[] arr = null;
- if (error == null) {
- assert args.length == 2;
- error = toError(args[0]);
- arr = toStringArray(args[1]);
- }
- done.doneGetEnvironment(token, error, arr);
- }
- }.token;
- }
-
- @SuppressWarnings("unchecked")
- private static String[] toStringArray(Object o) {
- if (o == null) return null;
- Collection<String> c = (Collection<String>)o;
- return (String[])c.toArray(new String[c.size()]);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/AbstractChannel.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/AbstractChannel.java
deleted file mode 100644
index fe8825f55..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/AbstractChannel.java
+++ /dev/null
@@ -1,953 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.core;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Map;
-
-import org.eclipse.tm.internal.tcf.core.ServiceManager;
-import org.eclipse.tm.internal.tcf.core.Token;
-import org.eclipse.tm.internal.tcf.core.TransportManager;
-import org.eclipse.tm.internal.tcf.services.local.LocatorService;
-import org.eclipse.tm.internal.tcf.services.remote.GenericProxy;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IErrorReport;
-import org.eclipse.tm.tcf.protocol.IPeer;
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.protocol.Protocol;
-import org.eclipse.tm.tcf.services.ILocator;
-
-/**
- * Abstract implementation of IChannel interface.
- *
- * AbstractChannel implements communication link connecting two end points (peers).
- * The channel asynchronously transmits messages: commands, results and events.
- *
- * Clients can subclass AbstractChannel to support particular transport (wire) protocol.
- * Also, see StreamChannel for stream oriented transport protocols.
- */
-public abstract class AbstractChannel implements IChannel {
-
- public interface TraceListener {
-
- public void onMessageReceived(char type, String token,
- String service, String name, byte[] data);
-
- public void onMessageSent(char type, String token,
- String service, String name, byte[] data);
-
- public void onChannelClosed(Throwable error);
- }
-
- public interface Proxy {
-
- public void onCommand(IToken token, String service, String name, byte[] data);
-
- public void onEvent(String service, String name, byte[] data);
-
- public void onChannelClosed(Throwable error);
- }
-
- private static class Message {
- final char type;
- Token token;
- String service;
- String name;
- byte[] data;
-
- boolean is_sent;
- boolean is_canceled;
-
- Collection<TraceListener> trace;
-
- Message(char type) {
- this.type = type;
- }
-
- @Override
- public String toString() {
- try {
- StringBuffer bf = new StringBuffer();
- bf.append('[');;
- bf.append(type);
- if (token != null) {
- bf.append(' ');
- bf.append(token.getID());
- }
- if (service != null) {
- bf.append(' ');
- bf.append(service);
- }
- if (name != null) {
- bf.append(' ');
- bf.append(name);
- }
- if (data != null) {
- int i = 0;
- while (i < data.length) {
- int j = i;
- while (j < data.length && data[j] != 0) j++;
- bf.append(' ');
- bf.append(new String(data, i, j - i, "UTF8"));
- if (j < data.length && data[j] == 0) j++;
- i = j;
- }
- }
- bf.append(']');
- return bf.toString();
- }
- catch (Exception x) {
- return x.toString();
- }
- }
- }
-
- private static IChannelListener[] listeners_array = new IChannelListener[4];
-
- private final LinkedList<String> redirect_queue = new LinkedList<String>();
- private final Map<Class<?>,IService> local_service_by_class = new HashMap<Class<?>,IService>();
- private final Map<Class<?>,IService> remote_service_by_class = new HashMap<Class<?>,IService>();
- private final Map<String,IService> local_service_by_name = new HashMap<String,IService>();
- private final Map<String,IService> remote_service_by_name = new HashMap<String,IService>();
- private final LinkedList<Message> out_queue = new LinkedList<Message>();
- private final Collection<IChannelListener> channel_listeners = new ArrayList<IChannelListener>();
- private final Map<String,IChannel.IEventListener[]> event_listeners = new HashMap<String,IChannel.IEventListener[]>();
- private final Map<String,IChannel.ICommandServer> command_servers = new HashMap<String,IChannel.ICommandServer>();
- private final Map<String,Message> out_tokens = new HashMap<String,Message>();
- private final Thread inp_thread;
- private final Thread out_thread;
- private boolean notifying_channel_opened;
- private boolean registered_with_trasport;
- private boolean shutdown;
- private int state = STATE_OPENNING;
- private IToken redirect_command;
- private final IPeer local_peer;
- private IPeer remote_peer;
- private Proxy proxy;
-
- private static final int pending_command_limit = 32;
- private int local_congestion_level = -100;
- private int remote_congestion_level = -100;
- private long local_congestion_time;
- private int local_congestion_cnt;
- private Collection<TraceListener> trace_listeners;
-
- public static final int
- EOS = -1, // End Of Stream
- EOM = -2; // End Of Message
-
- protected AbstractChannel(IPeer remote_peer) {
- this(LocatorService.getLocalPeer(), remote_peer);
- }
-
- protected AbstractChannel(IPeer local_peer, IPeer remote_peer) {
- assert Protocol.isDispatchThread();
- this.remote_peer = remote_peer;
- this.local_peer = local_peer;
-
- inp_thread = new Thread() {
-
- final byte[] empty_byte_array = new byte[0];
- byte[] buf = new byte[1024];
- byte[] eos;
-
- private void error() throws IOException {
- throw new IOException("Protocol syntax error");
- }
-
- private byte[] readBytes(int end) throws IOException {
- int len = 0;
- for (;;) {
- int n = read();
- if (n <= 0) {
- if (n == end) break;
- if (n == EOM) throw new IOException("Unexpected end of message");
- if (n < 0) throw new IOException("Communication channel is closed by remote peer");
- }
- if (len >= buf.length) {
- byte[] tmp = new byte[buf.length * 2];
- System.arraycopy(buf, 0, tmp, 0, len);
- buf = tmp;
- }
- buf[len++] = (byte)n;
- }
- if (len == 0) return empty_byte_array;
- byte[] res = new byte[len];
- System.arraycopy(buf, 0, res, 0, len);
- return res;
- }
-
- private String readString() throws IOException {
- int len = 0;
- for (;;) {
- int n = read();
- if (n <= 0) {
- if (n == 0) break;
- if (n == EOM) throw new IOException("Unexpected end of message");
- if (n < 0) throw new IOException("Communication channel is closed by remote peer");
- }
- if (len >= buf.length) {
- byte[] tmp = new byte[buf.length * 2];
- System.arraycopy(buf, 0, tmp, 0, len);
- buf = tmp;
- }
- buf[len++] = (byte)n;
- }
- return new String(buf, 0, len, "UTF8");
- }
-
- @Override
- public void run() {
- try {
- while (true) {
- int n = read();
- if (n == EOM) continue;
- if (n == EOS) {
- eos = readBytes(EOM);
- break;
- }
- final Message msg = new Message((char)n);
- if (read() != 0) error();
- switch (msg.type) {
- case 'C':
- msg.token = new Token(readBytes(0));
- msg.service = readString();
- msg.name = readString();
- msg.data = readBytes(EOM);
- break;
- case 'P':
- case 'R':
- case 'N':
- msg.token = new Token(readBytes(0));
- msg.data = readBytes(EOM);
- break;
- case 'E':
- msg.service = readString();
- msg.name = readString();
- msg.data = readBytes(EOM);
- break;
- case 'F':
- msg.data = readBytes(EOM);
- break;
- default:
- error();
- }
- Protocol.invokeLater(new Runnable() {
- public void run() {
- handleInput(msg);
- }
- });
- int delay = local_congestion_level;
- if (delay > 0) sleep(delay);
- }
- Protocol.invokeLater(new Runnable() {
- public void run() {
- if (out_tokens.isEmpty()) {
- close();
- }
- else {
- IOException x = new IOException("Connection reset by peer");
- try {
- Object[] args = JSON.parseSequence(eos);
- if (args.length > 0 && args[0] != null) {
- x = new IOException(Command.toErrorString(args[0]));
- }
- }
- catch (IOException e) {
- x = e;
- }
- terminate(x);
- }
- }
- });
- }
- catch (final Throwable x) {
- Protocol.invokeLater(new Runnable() {
- public void run() {
- terminate(x);
- }
- });
- }
- }
- };
-
- out_thread = new Thread() {
-
- @Override
- public void run() {
- try {
- while (true) {
- Message msg = null;
- boolean last = false;
- synchronized (out_queue) {
- while (out_queue.isEmpty()) out_queue.wait();
- msg = out_queue.removeFirst();
- if (msg == null) break;
- last = out_queue.isEmpty();
- if (msg.is_canceled) {
- if (last) flush();
- continue;
- }
- msg.is_sent = true;
- }
- if (msg.trace != null) {
- final Message m = msg;
- Protocol.invokeLater(new Runnable() {
- public void run() {
- for (TraceListener l : m.trace) {
- try {
- l.onMessageSent(m.type, m.token == null ? null : m.token.getID(),
- m.service, m.name, m.data);
- }
- catch (Throwable x) {
- Protocol.log("Exception in channel listener", x);
- }
- }
- }
- });
- }
- write(msg.type);
- write(0);
- if (msg.token != null) {
- write(msg.token.getBytes());
- write(0);
- }
- if (msg.service != null) {
- write(msg.service.getBytes("UTF8"));
- write(0);
- }
- if (msg.name != null) {
- write(msg.name.getBytes("UTF8"));
- write(0);
- }
- if (msg.data != null) {
- write(msg.data);
- }
- write(EOM);
- int delay = 0;
- int level = remote_congestion_level;
- if (level > 0) delay = level * 10;
- if (last || delay > 0) flush();
- if (delay > 0) sleep(delay);
- else yield();
- }
- write(EOS);
- write(EOM);
- flush();
- }
- catch (final Throwable x) {
- Protocol.invokeLater(new Runnable() {
- public void run() {
- terminate(x);
- }
- });
- }
- }
- };
- inp_thread.setName("TCF Channel Receiver");
- out_thread.setName("TCF Channel Transmitter");
- }
-
- protected void start() {
- assert Protocol.isDispatchThread();
- Protocol.invokeLater(new Runnable() {
- public void run() {
- try {
- if (proxy != null) return;
- ServiceManager.onChannelCreated(AbstractChannel.this, local_service_by_name);
- makeServiceByClassMap(local_service_by_name, local_service_by_class);
- Object[] args = new Object[]{ local_service_by_name.keySet() };
- sendEvent(Protocol.getLocator(), "Hello", JSON.toJSONSequence(args));
- }
- catch (IOException x) {
- terminate(x);
- }
- }
- });
- inp_thread.start();
- out_thread.start();
- }
-
- /**
- * Redirect this channel to given peer using this channel remote peer locator service as a proxy.
- * @param peer_id - peer that will become new remote communication endpoint of this channel
- */
- public void redirect(final String peer_id) {
- assert Protocol.isDispatchThread();
- if (state == STATE_OPENNING) {
- redirect_queue.add(peer_id);
- }
- else {
- assert state == STATE_OPEN;
- assert redirect_command == null;
- try {
- final ILocator l = (ILocator)remote_service_by_class.get(ILocator.class);
- if (l == null) throw new IOException("Cannot redirect channel: peer " +
- remote_peer.getID() + " has no locator service");
- final IPeer peer = l.getPeers().get(peer_id);
- if (peer == null) {
- // Peer not found, must wait for a while until peer is discovered or time out
- final boolean[] found = new boolean[1];
- Protocol.invokeLater(ILocator.DATA_RETENTION_PERIOD / 3, new Runnable() {
- public void run() {
- if (found[0]) return;
- terminate(new Exception("Peer " + peer_id + " not found"));
- }
- });
- l.addListener(new ILocator.LocatorListener() {
- public void peerAdded(IPeer peer) {
- if (peer.getID().equals(peer_id)) {
- found[0] = true;
- state = STATE_OPEN;
- l.removeListener(this);
- redirect(peer_id);
- }
- }
- public void peerChanged(IPeer peer) {
- }
-
- public void peerHeartBeat(String id) {
- }
-
- public void peerRemoved(String id) {
- }
- });
- }
- else {
- redirect_command = l.redirect(peer_id, new ILocator.DoneRedirect() {
- public void doneRedirect(IToken token, Exception x) {
- assert redirect_command == token;
- redirect_command = null;
- if (state != STATE_OPENNING) return;
- if (x != null) terminate(x);
- remote_peer = peer;
- remote_service_by_class.clear();
- remote_service_by_name.clear();
- event_listeners.clear();
- }
- });
- }
- state = STATE_OPENNING;
- }
- catch (Throwable x) {
- terminate(x);
- }
- }
- }
-
- private void makeServiceByClassMap(Map<String,IService> by_name, Map<Class<?>,IService> by_class) {
- for (IService service : by_name.values()) {
- for (Class<?> fs : service.getClass().getInterfaces()) {
- if (fs.equals(IService.class)) continue;
- if (!IService.class.isAssignableFrom(fs)) continue;
- by_class.put(fs, service);
- }
- }
- }
-
- public final int getState() {
- return state;
- }
-
- public void addChannelListener(IChannelListener listener) {
- assert Protocol.isDispatchThread();
- assert listener != null;
- channel_listeners.add(listener);
- }
-
- public void removeChannelListener(IChannelListener listener) {
- assert Protocol.isDispatchThread();
- channel_listeners.remove(listener);
- }
-
- public void addTraceListener(TraceListener listener) {
- if (trace_listeners == null) {
- trace_listeners = new ArrayList<TraceListener>();
- }
- else {
- trace_listeners = new ArrayList<TraceListener>(trace_listeners);
- }
- trace_listeners.add(listener);
- }
-
- public void removeTraceListener(TraceListener listener) {
- trace_listeners = new ArrayList<TraceListener>(trace_listeners);
- trace_listeners.remove(listener);
- if (trace_listeners.isEmpty()) trace_listeners = null;
- }
-
- public void addEventListener(IService service, IChannel.IEventListener listener) {
- assert Protocol.isDispatchThread();
- IChannel.IEventListener[] list = event_listeners.get(service.getName());
- IChannel.IEventListener[] next = new IChannel.IEventListener[list == null ? 1 : list.length + 1];
- if (list != null) System.arraycopy(list, 0, next, 0, list.length);
- next[next.length - 1] = listener;
- event_listeners.put(service.getName(), next);
- }
-
- public void removeEventListener(IService service, IChannel.IEventListener listener) {
- assert Protocol.isDispatchThread();
- IChannel.IEventListener[] list = event_listeners.get(service.getName());
- for (int i = 0; i < list.length; i++) {
- if (list[i] == listener) {
- if (list.length == 1) {
- event_listeners.remove(service.getName());
- }
- else {
- IChannel.IEventListener[] next = new IChannel.IEventListener[list.length - 1];
- System.arraycopy(list, 0, next, 0, i);
- System.arraycopy(list, i + 1, next, i, next.length - i);
- event_listeners.put(service.getName(), next);
- }
- return;
- }
- }
- }
-
- public void addCommandServer(IService service, IChannel.ICommandServer listener) {
- assert Protocol.isDispatchThread();
- if (command_servers.put(service.getName(), listener) != null) {
- throw new Error("Only one command server per service is allowed");
- }
- }
-
- public void removeCommandServer(IService service, IChannel.ICommandServer listener) {
- assert Protocol.isDispatchThread();
- if (command_servers.remove(service.getName()) != listener) {
- throw new Error("Invalid command server");
- }
- }
-
- private void sendEndOfStream() {
- if (shutdown) return;
- shutdown = true;
- synchronized (out_queue) {
- out_queue.clear();
- out_queue.add(0, null);
- out_queue.notify();
- }
- }
-
- public void close() {
- assert Protocol.isDispatchThread();
- try {
- sendEndOfStream();
- out_thread.join(10000);
- stop();
- inp_thread.join(10000);
- terminate(null);
- }
- catch (Exception x) {
- terminate(x);
- }
- }
-
- public void terminate(final Throwable error) {
- assert Protocol.isDispatchThread();
- sendEndOfStream();
- if (state == STATE_CLOSED) return;
- state = STATE_CLOSED;
- if (error != null && remote_peer instanceof AbstractPeer) {
- ((AbstractPeer)remote_peer).onChannelTerminated();
- }
- if (registered_with_trasport) {
- registered_with_trasport = false;
- TransportManager.channelClosed(this, error);
- }
- if (proxy != null) {
- try {
- proxy.onChannelClosed(error);
- }
- catch (Throwable x) {
- Protocol.log("Exception in channel listener", x);
- }
- }
- Protocol.invokeLater(new Runnable() {
- public void run() {
- if (!out_tokens.isEmpty()) {
- Exception x = null;
- if (error instanceof Exception) x = (Exception)error;
- else if (error != null) x = new Exception(error);
- else x = new IOException("Channel is closed");
- for (Message msg : out_tokens.values()) {
- String s = msg.toString();
- if (s.length() > 72) s = s.substring(0, 72) + "...]";
- IOException y = new IOException("Command " + s + " aborted");
- y.initCause(x);
- msg.token.getListener().terminated(msg.token, y);
- }
- out_tokens.clear();
- }
- if (channel_listeners.isEmpty()) {
- Protocol.log("TCF channel terminated", error);
- }
- else {
- listeners_array = channel_listeners.toArray(listeners_array);
- for (IChannelListener l : listeners_array) {
- if (l == null) break;
- try {
- l.onChannelClosed(error);
- }
- catch (Throwable x) {
- Protocol.log("Exception in channel listener", x);
- }
- }
- }
- if (trace_listeners != null) {
- for (TraceListener l : trace_listeners) {
- try {
- l.onChannelClosed(error);
- }
- catch (Throwable x) {
- Protocol.log("Exception in channel listener", x);
- }
- }
- }
- }
- });
- }
-
- public int getCongestion() {
- assert Protocol.isDispatchThread();
- int level = out_tokens.size() * 100 / pending_command_limit - 100;
- if (remote_congestion_level > level) level = remote_congestion_level;
- if (level > 100) level = 100;
- return level;
- }
-
- public IPeer getLocalPeer() {
- assert Protocol.isDispatchThread();
- return local_peer;
- }
-
- public IPeer getRemotePeer() {
- assert Protocol.isDispatchThread();
- return remote_peer;
- }
-
- public Collection<String> getLocalServices() {
- assert Protocol.isDispatchThread();
- assert state != STATE_OPENNING;
- return local_service_by_name.keySet();
- }
-
- public Collection<String> getRemoteServices() {
- assert Protocol.isDispatchThread();
- assert state != STATE_OPENNING;
- return remote_service_by_name.keySet();
- }
-
- @SuppressWarnings("unchecked")
- public <V extends IService> V getLocalService(Class<V> cls) {
- assert Protocol.isDispatchThread();
- assert state != STATE_OPENNING;
- return (V)local_service_by_class.get(cls);
- }
-
- @SuppressWarnings("unchecked")
- public <V extends IService> V getRemoteService(Class<V> cls) {
- assert Protocol.isDispatchThread();
- assert state != STATE_OPENNING;
- return (V)remote_service_by_class.get(cls);
- }
-
- public <V extends IService> void setServiceProxy(Class<V> service_interface, IService service_proxy) {
- if (!notifying_channel_opened) new Error("setServiceProxe() can be called only from channel open call-back");
- if (!(remote_service_by_name.get(service_proxy.getName()) instanceof GenericProxy)) throw new Error("Proxy already set");
- if (remote_service_by_class.get(service_interface) != null) throw new Error("Proxy already set");
- remote_service_by_class.put(service_interface, service_proxy);
- }
-
- public IService getLocalService(String service_name) {
- assert Protocol.isDispatchThread();
- assert state != STATE_OPENNING;
- return local_service_by_name.get(service_name);
- }
-
- public IService getRemoteService(String service_name) {
- assert Protocol.isDispatchThread();
- assert state != STATE_OPENNING;
- return remote_service_by_name.get(service_name);
- }
-
- public void setProxy(Proxy proxy, Collection<String> services) throws IOException {
- this.proxy = proxy;
- sendEvent(Protocol.getLocator(), "Hello", JSON.toJSONSequence(new Object[]{ services }));
- local_service_by_class.clear();
- local_service_by_name.clear();
- }
-
- private void addToOutQueue(Message msg) {
- msg.trace = trace_listeners;
- synchronized (out_queue) {
- out_queue.add(msg);
- out_queue.notify();
- }
- }
-
- public IToken sendCommand(IService service, String name, byte[] args, ICommandListener listener) {
- assert Protocol.isDispatchThread();
- if (state == STATE_OPENNING) throw new Error("Channel is waiting for Hello message");
- if (state == STATE_CLOSED) throw new Error("Channel is closed");
- final Message msg = new Message('C');
- msg.service = service.getName();
- msg.name = name;
- msg.data = args;
- Token token = new Token(listener) {
- @Override
- public boolean cancel() {
- assert Protocol.isDispatchThread();
- if (state != STATE_OPEN) return false;
- synchronized (out_queue) {
- if (msg.is_sent) return false;
- msg.is_canceled = true;
- }
- out_tokens.remove(msg.token.getID());
- return true;
- }
- };
- msg.token = token;
- out_tokens.put(token.getID(), msg);
- addToOutQueue(msg);
- return token;
- }
-
- public void sendProgress(IToken token, byte[] results) {
- assert Protocol.isDispatchThread();
- if (state != STATE_OPEN) throw new Error("Channel is closed");
- Message msg = new Message('P');
- msg.data = results;
- msg.token = (Token)token;
- addToOutQueue(msg);
- }
-
- public void sendResult(IToken token, byte[] results) {
- assert Protocol.isDispatchThread();
- if (state != STATE_OPEN) throw new Error("Channel is closed");
- Message msg = new Message('R');
- msg.data = results;
- msg.token = (Token)token;
- addToOutQueue(msg);
- }
-
- public void rejectCommand(IToken token) {
- assert Protocol.isDispatchThread();
- if (state != STATE_OPEN) throw new Error("Channel is closed");
- Message msg = new Message('N');
- msg.token = (Token)token;
- addToOutQueue(msg);
- }
-
- public void sendEvent(IService service, String name, byte[] args) {
- assert Protocol.isDispatchThread();
- if (!(state == STATE_OPEN || state == STATE_OPENNING && service instanceof ILocator)) {
- throw new Error("Channel is closed");
- }
- Message msg = new Message('E');
- msg.service = service.getName();
- msg.name = name;
- msg.data = args;
- addToOutQueue(msg);
- }
-
- @SuppressWarnings("unchecked")
- private void handleInput(Message msg) {
- assert Protocol.isDispatchThread();
- if (state == STATE_CLOSED) return;
- if (trace_listeners != null) {
- for (TraceListener l : trace_listeners) {
- try {
- l.onMessageReceived(msg.type,
- msg.token != null ? msg.token.getID() : null,
- msg.service, msg.name, msg.data);
- }
- catch (Throwable x) {
- Protocol.log("Exception in trace listener", x);
- }
- }
- }
- try {
- Token token = null;
- switch (msg.type) {
- case 'C':
- if (state == STATE_OPENNING) {
- throw new IOException("Received command " + msg.service + "." + msg.name + " before Hello message");
- }
- if (proxy != null) {
- proxy.onCommand(msg.token, msg.service, msg.name, msg.data);
- }
- else {
- token = msg.token;
- IChannel.ICommandServer cmds = command_servers.get(msg.service);
- if (cmds != null) {
- cmds.command(token, msg.name, msg.data);
- }
- else {
- rejectCommand(token);
- }
- }
- break;
- case 'P':
- token = out_tokens.get(msg.token.getID()).token;
- token.getListener().progress(token, msg.data);
- sendCongestionLevel();
- break;
- case 'R':
- token = out_tokens.remove(msg.token.getID()).token;
- token.getListener().result(token, msg.data);
- sendCongestionLevel();
- break;
- case 'N':
- token = out_tokens.remove(msg.token.getID()).token;
- token.getListener().terminated(token, new ErrorReport(
- "Command is not recognized", IErrorReport.TCF_ERROR_INV_COMMAND));
- break;
- case 'E':
- boolean hello = msg.service.equals(ILocator.NAME) && msg.name.equals("Hello");
- if (hello) {
- remote_service_by_name.clear();
- remote_service_by_class.clear();
- ServiceManager.onChannelOpened(this, (Collection<String>)JSON.parseSequence(msg.data)[0], remote_service_by_name);
- makeServiceByClassMap(remote_service_by_name, remote_service_by_class);
- }
- if (proxy != null && state == STATE_OPEN) {
- proxy.onEvent(msg.service, msg.name, msg.data);
- }
- else if (hello) {
- assert state == STATE_OPENNING;
- state = STATE_OPEN;
- assert redirect_command == null;
- if (redirect_queue.size() > 0) {
- redirect(redirect_queue.removeFirst());
- }
- else {
- notifying_channel_opened = true;
- if (!registered_with_trasport) {
- TransportManager.channelOpened(this);
- registered_with_trasport = true;
- }
- listeners_array = channel_listeners.toArray(listeners_array);
- for (IChannelListener l : listeners_array) {
- if (l == null) break;
- try {
- l.onChannelOpened();
- }
- catch (Throwable x) {
- Protocol.log("Exception in channel listener", x);
- }
- }
- notifying_channel_opened = false;
- }
- }
- else {
- IChannel.IEventListener[] list = event_listeners.get(msg.service);
- if (list != null) {
- for (int i = 0; i < list.length; i++) {
- list[i].event(msg.name, msg.data);
- }
- }
- sendCongestionLevel();
- }
- break;
- case 'F':
- int len = msg.data.length;
- if (len > 0 && msg.data[len - 1] == 0) len--;
- remote_congestion_level = Integer.parseInt(new String(msg.data, 0, len, "ASCII"));
- break;
- default:
- assert false;
- break;
- }
- }
- catch (Throwable x) {
- terminate(x);
- }
- }
-
- private void sendCongestionLevel() throws IOException {
- if (++local_congestion_cnt < 8) return;
- local_congestion_cnt = 0;
- if (state != STATE_OPEN) return;
- long time = System.currentTimeMillis();
- if (time - local_congestion_time < 500) return;
- assert Protocol.isDispatchThread();
- int level = Protocol.getCongestionLevel();
- if (level == local_congestion_level) return;
- int i = (level - local_congestion_level) / 8;
- if (i != 0) level = local_congestion_level + i;
- local_congestion_time = time;
- synchronized (out_queue) {
- Message msg = out_queue.isEmpty() ? null : out_queue.get(0);
- if (msg == null || msg.type != 'F') {
- msg = new Message('F');
- out_queue.add(0, msg);
- out_queue.notify();
- }
- StringBuilder buffer = new StringBuilder();
- buffer.append(local_congestion_level);
- buffer.append((char)0); // 0 terminate
- msg.data = buffer.toString().getBytes("ASCII");
- msg.trace = trace_listeners;
- local_congestion_level = level;
- }
- }
-
- /**
- * Read one byte from the channel input stream.
- * @return next data byte or EOS (-1) if end of stream is reached,
- * or EOM (-2) if end of message is reached.
- * @throws IOException
- */
- protected abstract int read() throws IOException;
-
- /**
- * Write one byte into the channel output stream.
- * The method argument can be one of two special values:
- * EOS (-1) end of stream marker;
- * EOM (-2) end of message marker.
- * The stream can put the byte into a buffer instead of transmitting it right away.
- * @param n - the data byte.
- * @throws IOException
- */
- protected abstract void write(int n) throws IOException;
-
- /**
- * Flush the channel output stream.
- * All buffered data should be transmitted immediately.
- * @throws IOException
- */
- protected abstract void flush() throws IOException;
-
- /**
- * Stop (close) channel underlying streams.
- * If a thread is blocked by read() or write(), it should be
- * resumed (or interrupted).
- * @throws IOException
- */
- protected abstract void stop() throws IOException;
-
- /**
- * Write array of bytes into the channel output stream.
- * The stream can put bytes into a buffer instead of transmitting it right away.
- * @param buf
- * @throws IOException
- */
- protected void write(byte[] buf) throws IOException {
- assert Thread.currentThread() == out_thread;
- for (int i = 0; i < buf.length; i++) write(buf[i]);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/AbstractPeer.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/AbstractPeer.java
deleted file mode 100644
index 1b857356b..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/AbstractPeer.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.core;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.tm.internal.tcf.core.TransportManager;
-import org.eclipse.tm.internal.tcf.services.local.LocatorService;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IPeer;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.protocol.Protocol;
-import org.eclipse.tm.tcf.services.ILocator;
-import org.eclipse.tm.tcf.services.ILocator.LocatorListener;
-
-/**
- * Abstract implementation of IPeer interface.
- */
-public abstract class AbstractPeer implements IPeer {
-
- private final Map<String, String> ro_attrs;
- private final Map<String, String> rw_attrs;
-
- private long last_heart_beat_time;
-
- public AbstractPeer(Map<String,String> attrs) {
- assert Protocol.isDispatchThread();
- if (attrs != null) {
- rw_attrs = new HashMap<String, String>(attrs);
- }
- else {
- rw_attrs = new HashMap<String, String>();
- }
- ro_attrs = Collections.unmodifiableMap(rw_attrs);
- assert getID() != null;
- LocatorService.addPeer(this);
- }
-
- void onChannelTerminated() {
- // A channel to this peer was terminated:
- // not delaying next heart beat helps client to recover much faster.
- last_heart_beat_time = 0;
- }
-
- public void updateAttributes(Map<String,String> attrs) {
- boolean equ = true;
- assert attrs.get(ATTR_ID).equals(rw_attrs.get(ATTR_ID));
- for (Iterator<String> i = rw_attrs.keySet().iterator(); i.hasNext();) {
- String key = i.next();
- if (!rw_attrs.get(key).equals(attrs.get(key))) {
- equ = false;
- break;
- }
- }
- for (Iterator<String> i = attrs.keySet().iterator(); i.hasNext();) {
- String key = i.next();
- if (!attrs.get(key).equals(rw_attrs.get(key))) {
- equ = false;
- break;
- }
- }
- long time = System.currentTimeMillis();
- if (!equ) {
- rw_attrs.clear();
- rw_attrs.putAll(attrs);
- for (LocatorListener l : LocatorService.getListeners()) {
- try {
- l.peerChanged(this);
- }
- catch (Throwable x) {
- Protocol.log("Unhandled exception in Locator listener", x);
- }
- }
- try {
- Object[] args = { rw_attrs };
- Protocol.sendEvent(ILocator.NAME, "peerChanged", JSON.toJSONSequence(args));
- }
- catch (IOException x) {
- Protocol.log("Locator: failed to send 'peerChanged' event", x);
- }
- last_heart_beat_time = time;
- }
- else if (last_heart_beat_time + ILocator.DATA_RETENTION_PERIOD / 4 < time) {
- for (LocatorListener l : LocatorService.getListeners()) {
- try {
- l.peerHeartBeat(attrs.get(ATTR_ID));
- }
- catch (Throwable x) {
- Protocol.log("Unhandled exception in Locator listener", x);
- }
- }
- try {
- Object[] args = { rw_attrs.get(ATTR_ID) };
- Protocol.sendEvent(ILocator.NAME, "peerHeartBeat", JSON.toJSONSequence(args));
- }
- catch (IOException x) {
- Protocol.log("Locator: failed to send 'peerHeartBeat' event", x);
- }
- last_heart_beat_time = time;
- }
- }
-
- public void sendPeerAddedEvent() {
- for (LocatorListener l : LocatorService.getListeners()) {
- try {
- l.peerAdded(this);
- }
- catch (Throwable x) {
- Protocol.log("Unhandled exception in Locator listener", x);
- }
- }
- try {
- Object[] args = { rw_attrs };
- Protocol.sendEvent(ILocator.NAME, "peerAdded", JSON.toJSONSequence(args));
- }
- catch (IOException x) {
- Protocol.log("Locator: failed to send 'peerAdded' event", x);
- }
- last_heart_beat_time = System.currentTimeMillis();
- }
-
- public void sendPeerRemovedEvent() {
- for (LocatorListener l : LocatorService.getListeners()) {
- try {
- l.peerRemoved(rw_attrs.get(ATTR_ID));
- }
- catch (Throwable x) {
- Protocol.log("Unhandled exception in Locator listener", x);
- }
- }
- try {
- Object[] args = { rw_attrs.get(ATTR_ID) };
- Protocol.sendEvent(ILocator.NAME, "peerRemoved", JSON.toJSONSequence(args));
- }
- catch (IOException x) {
- Protocol.log("Locator: failed to send 'peerRemoved' event", x);
- }
- }
-
- public void dispose() {
- assert Protocol.isDispatchThread();
- TransportManager.peerDisposed(this);
- LocatorService.removePeer(this);
- }
-
- public Map<String,String> getAttributes() {
- assert Protocol.isDispatchThread();
- return ro_attrs;
- }
-
- public String getID() {
- assert Protocol.isDispatchThread();
- return ro_attrs.get(ATTR_ID);
- }
-
- public String getName() {
- assert Protocol.isDispatchThread();
- return ro_attrs.get(ATTR_NAME);
- }
-
- public String getOSName() {
- assert Protocol.isDispatchThread();
- return ro_attrs.get(ATTR_OS_NAME);
- }
-
- public String getTransportName() {
- assert Protocol.isDispatchThread();
- return ro_attrs.get(ATTR_TRANSPORT_NAME);
- }
-
- public IChannel openChannel() {
- return TransportManager.openChannel(this);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/Base64.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/Base64.java
deleted file mode 100644
index 2a8ea72fa..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/Base64.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.core;
-
-/**
- * Methods for translating Base64 encoded strings to byte arrays and back.
- * @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public final class Base64 {
-
- public static char[] toBase64(byte[] buf, int pos, int len) {
- char[] out_buf = new char[4 * ((len + 2) / 3)];
- int end = pos + len;
- int out_pos = 0;
- while (pos < end) {
- int byte0 = buf[pos++] & 0xff;
- out_buf[out_pos++] = int2char[byte0 >> 2];
- if (pos == end) {
- out_buf[out_pos++] = int2char[(byte0 << 4) & 0x3f];
- out_buf[out_pos++] = '=';
- out_buf[out_pos++] = '=';
- }
- else {
- int byte1 = buf[pos++] & 0xff;
- out_buf[out_pos++] = int2char[(byte0 << 4) & 0x3f | (byte1 >> 4)];
- if (pos == end) {
- out_buf[out_pos++] = int2char[(byte1 << 2) & 0x3f];
- out_buf[out_pos++] = '=';
- }
- else {
- int byte2 = buf[pos++] & 0xff;
- out_buf[out_pos++] = int2char[(byte1 << 2) & 0x3f | (byte2 >> 6)];
- out_buf[out_pos++] = int2char[byte2 & 0x3f];
- }
- }
- }
- assert out_pos == out_buf.length;
- return out_buf;
- }
-
- public static void toByteArray(byte[] buf, int offs, int size, char[] inp) {
- int out_pos = offs;
- if (inp != null) {
- int inp_len = inp.length;
- if (inp_len % 4 != 0) {
- throw new IllegalArgumentException(
- "BASE64 string length must be a multiple of four.");
- }
- int out_len = inp_len / 4 * 3;
- if (inp_len > 0 && inp[inp_len - 1] == '=') {
- out_len--;
- if (inp[inp_len - 2] == '=') {
- out_len--;
- }
- }
- if (out_len > size) {
- throw new IllegalArgumentException(
- "BASE64 data array is longer then destination buffer.");
- }
- int inp_pos = 0;
- while (inp_pos < inp_len) {
- int n0, n1, n2, n3;
- char ch0 = inp[inp_pos++];
- char ch1 = inp[inp_pos++];
- char ch2 = inp[inp_pos++];
- char ch3 = inp[inp_pos++];
- if (ch0 >= char2int.length || (n0 = char2int[ch0]) < 0) {
- throw new IllegalArgumentException("Illegal character " + ch0);
- }
- if (ch1 >= char2int.length || (n1 = char2int[ch1]) < 0) {
- throw new IllegalArgumentException("Illegal character " + ch1);
- }
- buf[out_pos++] = (byte)((n0 << 2) | (n1 >> 4));
- if (ch2 == '=') break;
- if (ch2 >= char2int.length || (n2 = char2int[ch2]) < 0) {
- throw new IllegalArgumentException("Illegal character " + ch2);
- }
- buf[out_pos++] = (byte)((n1 << 4) | (n2 >> 2));
- if (ch3 == '=') break;
- if (ch3 >= char2int.length || (n3 = char2int[ch3]) < 0) {
- throw new IllegalArgumentException("Illegal character " + ch3);
- }
- buf[out_pos++] = (byte)((n2 << 6) | n3);
- }
- assert out_pos == offs + out_len;
- }
- while (out_pos < offs + size) buf[out_pos++] = 0;
- }
-
- public static byte[] toByteArray(char[] inp) {
- int inp_len = inp.length;
- int out_len = inp_len / 4 * 3;
- if (inp_len > 0 && inp[inp_len - 1] == '=') {
- out_len--;
- if (inp[inp_len - 2] == '=') {
- out_len--;
- }
- }
- byte[] buf = new byte[out_len];
- toByteArray(buf, 0, buf.length, inp);
- return buf;
- }
-
- /*
- * See RFC 2045.
- */
- private static final char int2char[] = {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
- 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
- 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
- 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
- 'w', 'x', 'y', 'z', '0', '1', '2', '3',
- '4', '5', '6', '7', '8', '9', '+', '/'
- };
-
- /*
- * See RFC 2045
- */
- private static final byte char2int[] = {
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 62, -1, -1, -1, 63,
- 52, 53, 54, 55, 56, 57, 58, 59,
- 60, 61, -1, -1, -1, -1, -1, -1,
- -1, 0, 1, 2, 3, 4, 5, 6,
- 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, -1, -1, -1, -1, -1,
- -1, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48,
- 49, 50, 51
- };
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/ChannelTCP.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/ChannelTCP.java
deleted file mode 100644
index fc4b0d5ae..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/ChannelTCP.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.core;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-import java.net.SocketException;
-
-import org.eclipse.tm.tcf.protocol.IPeer;
-import org.eclipse.tm.tcf.protocol.Protocol;
-
-/**
- * ChannelTCP is a IChannel implementation that works on top of TCP sockets as a transport.
- */
-public class ChannelTCP extends StreamChannel {
-
- private Socket socket;
- private InputStream inp;
- private OutputStream out;
- private boolean closed;
-
- public ChannelTCP(IPeer remote_peer, final String host, final int port) {
- super(remote_peer);
- Thread thread = new Thread() {
- public void run() {
- try {
- socket = new Socket(host, port);
- socket.setTcpNoDelay(true);
- inp = new BufferedInputStream(socket.getInputStream());
- out = new BufferedOutputStream(socket.getOutputStream());
- Protocol.invokeLater(new Runnable() {
- public void run() {
- ChannelTCP.this.start();
- }
- });
- }
- catch (final IOException x) {
- Protocol.invokeLater(new Runnable() {
- public void run() {
- ChannelTCP.this.terminate(x);
- }
- });
- }
- }
- };
- thread.setName("TCF Socket Connect");
- thread.start();
- }
-
- public ChannelTCP(IPeer local_peer, IPeer remote_peer, Socket socket) throws IOException {
- super(local_peer, remote_peer);
- this.socket = socket;
- socket.setTcpNoDelay(true);
- inp = new BufferedInputStream(socket.getInputStream());
- out = new BufferedOutputStream(socket.getOutputStream());
- start();
- }
-
- @Override
- protected final int get() throws IOException {
- try {
- if (closed) return -1;
- return inp.read();
- }
- catch (SocketException x) {
- if (closed) return -1;
- throw x;
- }
- }
-
- @Override
- protected final void put(int b) throws IOException {
- assert b >= 0 && b <= 0xff;
- if (closed) return;
- out.write(b);
- }
-
- @Override
- protected final void flush() throws IOException {
- if (closed) return;
- out.flush();
- }
-
- @Override
- protected void stop() throws IOException {
- closed = true;
- socket.close();
- out.close();
- inp.close();
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/Command.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/Command.java
deleted file mode 100644
index 7748e15c7..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/Command.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.core;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Map;
-
-import org.eclipse.tm.internal.tcf.core.Token;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IErrorReport;
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.JSON;
-import org.eclipse.tm.tcf.protocol.Protocol;
-
-
-/**
- * This is utility class that helps to implement sending a command and receiving
- * command result over TCF communication channel. The class uses JSON to encode
- * command arguments and to decode result data.
- *
- * The class also provides support for TCF standard error report encoding.
- *
- * Clients are expected to subclass <code>Command</code> and override <code>done</code> method.
- *
- * Note: most clients don't need to handle protocol commands directly and
- * can use service APIs instead. Service API does all command encoding/decoding
- * for a client.
- *
- * Typical usage example:
- *
- * public IToken getContext(String id, final DoneGetContext done) {
- * return new Command(channel, IService.this, "getContext", new Object[]{ id }) {
- * @Override
- * public void done(Exception error, Object[] args) {
- * Context ctx = null;
- * if (error == null) {
- * assert args.length == 2;
- * error = toError(args[0]);
- * if (args[1] != null) ctx = new Context(args[1]);
- * }
- * done.doneGetContext(token, error, ctx);
- * }
- * }.token;
- * }
- */
-public abstract class Command implements IChannel.ICommandListener {
-
- private final IService service;
- private final String command;
- private final Object[] args;
-
- public final IToken token;
-
- private boolean done;
-
- private static final SimpleDateFormat timestamp_format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-
- public Command(IChannel channel, IService service, String command, Object[] args) {
- this.service = service;
- this.command = command;
- this.args = args;
- IToken t = null;
- try {
- t = channel.sendCommand(service, command, JSON.toJSONSequence(args), this);
- }
- catch (Throwable y) {
- t = new Token();
- final Exception x = y instanceof Exception ? (Exception)y : new Exception(y);
- Protocol.invokeLater(new Runnable() {
- public void run() {
- assert !done;
- done = true;
- done(x, null);
- }
- });
- }
- token = t;
- }
-
- public void progress(IToken token, byte[] data) {
- assert this.token == token;
- }
-
- public void result(IToken token, byte[] data) {
- assert this.token == token;
- Exception error = null;
- Object[] args = null;
- try {
- args = JSON.parseSequence(data);
- }
- catch (Exception e) {
- error = e;
- }
- assert !done;
- done = true;
- done(error, args);
- }
-
- public void terminated(IToken token, Exception error) {
- assert this.token == token;
- assert !done;
- done = true;
- done(error, null);
- }
-
- public abstract void done(Exception error, Object[] args);
-
- public String getCommandString() {
- StringBuffer buf = new StringBuffer();
- buf.append(service.getName());
- buf.append(' ');
- buf.append(command);
- if (args != null) {
- for (int i = 0; i < args.length; i++) {
- buf.append(i == 0 ? " " : ", ");
- try {
- buf.append(JSON.toJSON(args[i]));
- }
- catch (IOException x) {
- buf.append("***");
- buf.append(x.getMessage());
- buf.append("***");
- }
- }
- }
- return buf.toString();
- }
-
- @SuppressWarnings({ "unchecked" })
- public static String toErrorString(Object data) {
- if (data == null) return null;
- Map<String,Object> map = (Map<String,Object>)data;
- String fmt = (String)map.get(IErrorReport.ERROR_FORMAT);
- if (fmt != null) {
- Collection<Object> c = (Collection<Object>)map.get(IErrorReport.ERROR_PARAMS);
- if (c != null) return new MessageFormat(fmt).format(c.toArray());
- return fmt;
- }
- Number code = (Number)map.get(IErrorReport.ERROR_CODE);
- if (code != null) {
- if (code.intValue() == IErrorReport.TCF_ERROR_OTHER) {
- String alt_org = (String)map.get(IErrorReport.ERROR_ALT_ORG);
- Number alt_code = (Number)map.get(IErrorReport.ERROR_ALT_CODE);
- if (alt_org != null && alt_code != null) {
- return alt_org + " Error " + alt_code;
- }
- }
- return "TCF Error " + code;
- }
- return "Invalid error report format";
- }
-
- static void appendErrorProps(StringBuffer bf, Map<String,Object> map) {
- Number time = (Number)map.get(IErrorReport.ERROR_TIME);
- Number code = (Number)map.get(IErrorReport.ERROR_CODE);
- String service = (String)map.get(IErrorReport.ERROR_SERVICE);
- Number severity = (Number)map.get(IErrorReport.ERROR_SEVERITY);
- Number alt_code = (Number)map.get(IErrorReport.ERROR_ALT_CODE);
- String alt_org = (String)map.get(IErrorReport.ERROR_ALT_ORG);
- if (time != null) {
- bf.append('\n');
- bf.append("Time: ");
- bf.append(timestamp_format.format(new Date(time.longValue())));
- }
- if (severity != null) {
- bf.append('\n');
- bf.append("Severity: ");
- bf.append(toErrorString(map));
- switch (severity.intValue()) {
- case IErrorReport.SEVERITY_ERROR: bf.append("Error");
- case IErrorReport.SEVERITY_FATAL: bf.append("Fatal");
- case IErrorReport.SEVERITY_WARNING: bf.append("Warning");
- default: bf.append("Unknown");
- }
- }
- bf.append('\n');
- bf.append("Error text: ");
- bf.append(toErrorString(map));
- bf.append('\n');
- bf.append("Error code: ");
- bf.append(code);
- if (service != null) {
- bf.append('\n');
- bf.append("Service: ");
- bf.append(service);
- }
- if (alt_code != null) {
- bf.append('\n');
- bf.append("Alt code: ");
- bf.append(alt_code);
- if (alt_org != null) {
- bf.append('\n');
- bf.append("Alt org: ");
- bf.append(alt_org);
- }
- }
- }
-
- public Exception toError(Object data) {
- return toError(data, true);
- }
-
- @SuppressWarnings("unchecked")
- public Exception toError(Object data, boolean include_command_text) {
- if (data == null) return null;
- Map<String,Object> map = (Map<String,Object>)data;
- StringBuffer bf = new StringBuffer();
- bf.append("TCF error report:");
- bf.append('\n');
- if (include_command_text) {
- String cmd = getCommandString();
- if (cmd.length() > 72) cmd = cmd.substring(0, 72) + "...";
- bf.append("Command: ");
- bf.append(cmd);
- }
- appendErrorProps(bf, map);
- return new ErrorReport(bf.toString(), map);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/ErrorReport.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/ErrorReport.java
deleted file mode 100644
index 56dbca80e..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/ErrorReport.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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.tm.tcf.core;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IErrorReport;
-
-class ErrorReport extends Exception implements IErrorReport {
-
- private static final long serialVersionUID = 3687543884858739977L;
- private final Map<String,Object> attrs;
-
- @SuppressWarnings("unchecked")
- ErrorReport(String msg, Map<String,Object> attrs) {
- super(msg);
- this.attrs = attrs;
- Object caused_by = attrs.get(IErrorReport.ERROR_CAUSED_BY);
- if (caused_by != null) {
- Map<String,Object> map = (Map<String,Object>)caused_by;
- StringBuffer bf = new StringBuffer();
- bf.append("TCF error report:");
- bf.append('\n');
- Command.appendErrorProps(bf, map);
- initCause(new ErrorReport(bf.toString(), map));
- }
- }
-
- ErrorReport(String msg, int code) {
- super(msg);
- attrs = new HashMap<String,Object>();
- attrs.put(ERROR_CODE, code);
- attrs.put(ERROR_TIME, System.currentTimeMillis());
- attrs.put(ERROR_FORMAT, msg);
- attrs.put(ERROR_SEVERITY, SEVERITY_ERROR);
- }
-
- public int getErrorCode() {
- Number n = (Number)attrs.get(ERROR_CODE);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public int getAltCode() {
- Number n = (Number)attrs.get(ERROR_ALT_CODE);
- if (n == null) return 0;
- return n.intValue();
- }
-
- public String getAltOrg() {
- return (String)attrs.get(ERROR_ALT_ORG);
- }
-
- public Map<String, Object> getAttributes() {
- return attrs;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/ServerTCP.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/ServerTCP.java
deleted file mode 100644
index 70d14924b..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/ServerTCP.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.tm.tcf.core;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IPeer;
-import org.eclipse.tm.tcf.protocol.Protocol;
-
-/**
- * ServerTCP is a TCP server that is listening for incoming connection requests
- * and creates TCF communication channels over TCP sockets for such requests.
- *
- * Clients may create objects of this class to become a TCF server.
- */
-public class ServerTCP extends ServerSocket {
-
- private static class ServerPeer extends AbstractPeer {
- ServerPeer(Map<String,String> attrs) {
- super(attrs);
- }
- }
-
- private static class RemotePeer extends AbstractPeer {
- RemotePeer(Map<String,String> attrs) {
- super(attrs);
- }
- }
-
- private final String name;
- private List<ServerPeer> peers;
- private Thread thread;
-
- public ServerTCP(String name, int port) throws IOException {
- super(port);
- this.name = name;
- peers = new ArrayList<ServerPeer>();
- Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
- while (e.hasMoreElements()) {
- NetworkInterface f = e.nextElement();
- Enumeration<InetAddress> n = f.getInetAddresses();
- while (n.hasMoreElements()) {
- peers.add(getLocalPeer(n.nextElement().getHostAddress()));
- }
- }
- thread = new Thread() {
- @Override
- public void run() {
- while (true) {
- try {
- final Socket socket = accept();
- Protocol.invokeLater(new Runnable() {
- public void run() {
- try {
- new ChannelTCP(getLocalPeer(socket), getRemotePeer(socket), socket);
- }
- catch (final Throwable x) {
- Protocol.log("TCF Server: failed to create a channel", x);
- }
- }
- });
- }
- catch (final Throwable x) {
- Protocol.invokeLater(new Runnable() {
- public void run() {
- Protocol.log("TCF Server thread aborted", x);
- }
- });
- break;
- }
- }
- }
- };
- thread.setName(name);
- thread.setDaemon(true);
- thread.start();
- }
-
- private ServerPeer getLocalPeer(String addr) {
- for (ServerPeer p : peers) {
- if (addr.equals(p.getAttributes().get(IPeer.ATTR_IP_HOST))) return p;
- }
- Map<String,String> attrs = new HashMap<String,String>();
- attrs.put(IPeer.ATTR_ID, "TCP:" + addr + ":" + getLocalPort());
- attrs.put(IPeer.ATTR_NAME, name);
- attrs.put(IPeer.ATTR_OS_NAME, System.getProperty("os.name"));
- attrs.put(IPeer.ATTR_TRANSPORT_NAME, "TCP");
- attrs.put(IPeer.ATTR_IP_HOST, addr);
- attrs.put(IPeer.ATTR_IP_PORT, Integer.toString(getLocalPort()));
- attrs.put(IPeer.ATTR_PROXY, "");
- ServerPeer p = new ServerPeer(attrs);
- peers.add(p);
- return p;
- }
-
- private IPeer getLocalPeer(Socket socket) {
- return getLocalPeer(socket.getLocalAddress().getHostAddress());
- }
-
- private IPeer getRemotePeer(Socket socket) {
- String addr = socket.getInetAddress().getHostAddress();
- for (IPeer p : Protocol.getLocator().getPeers().values()) {
- if (addr.equals(p.getAttributes().get(IPeer.ATTR_IP_HOST))) return p;
- }
- Map<String,String> attrs = new HashMap<String,String>();
- attrs.put(IPeer.ATTR_ID, "TCP:" + addr + ":");
- attrs.put(IPeer.ATTR_TRANSPORT_NAME, "TCP");
- attrs.put(IPeer.ATTR_IP_HOST, addr);
- return new RemotePeer(attrs);
- }
-
- @Override
- public void close() throws IOException {
- if (peers != null) {
- for (ServerPeer s : peers) s.dispose();
- peers = null;
- }
- super.close();
- if (thread != null) {
- try {
- thread.join();
- thread = null;
- }
- catch (InterruptedException e) {
- throw new InterruptedIOException();
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/StreamChannel.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/StreamChannel.java
deleted file mode 100644
index b9020729a..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/core/StreamChannel.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.core;
-
-import java.io.IOException;
-
-import org.eclipse.tm.tcf.protocol.IPeer;
-
-/**
- * Abstract implementation of IChannel interface for stream oriented transport protocols.
- *
- * StreamChannel implements communication link connecting two end points (peers).
- * The channel asynchronously transmits messages: commands, results and events.
- *
- * StreamChannel uses escape sequences to represent End-Of-Message and End-Of-Stream markers.
- *
- * Clients can subclass StreamChannel to support particular stream oriented transport (wire) protocol.
- * Also, see ChannelTCP for a concrete IChannel implementation that works on top of TCP sockets as a transport.
- */
-public abstract class StreamChannel extends AbstractChannel {
-
- public static final int ESC = 3;
-
- public StreamChannel(IPeer remote_peer) {
- super(remote_peer);
- }
-
- public StreamChannel(IPeer local_peer, IPeer remote_peer) {
- super(local_peer, remote_peer);
- }
-
- protected abstract int get() throws IOException;
- protected abstract void put(int n) throws IOException;
-
- @Override
- protected final int read() throws IOException {
- int res = get();
- if (res < 0) return EOS;
- assert res >= 0 && res <= 0xff;
- if (res != ESC) return res;
- int n = get();
- switch (n) {
- case 0: return ESC;
- case 1: return EOM;
- case 2: return EOS;
- default:
- if (n < 0) return EOS;
- assert false;
- return 0;
- }
- }
-
- @Override
- protected final void write(int n) throws IOException {
- switch (n) {
- case ESC: put(ESC); put(0); break;
- case EOM: put(ESC); put(1); break;
- case EOS: put(ESC); put(2); break;
- default:
- assert n >= 0 && n <= 0xff;
- put(n);
- }
- }
-
- @Override
- protected void write(byte[] buf) throws IOException {
- for (int i = 0; i < buf.length; i++) {
- int n = buf[i] & 0xff;
- put(n);
- if (n == ESC) put(0);
- }
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IChannel.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IChannel.java
deleted file mode 100644
index 23f6e59b7..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IChannel.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.protocol;
-
-import java.util.Collection;
-
-/**
- * IChannel represents communication link connecting two end points (peers).
- * The channel asynchronously transmits messages: commands, results and events.
- * A single channel may be used to communicate with multiple services.
- * Multiple channels may be used to connect the same peers, however no command or event
- * ordering is guaranteed across channels.
- *
- * @noimplement This interface is not intended to be implemented by clients.
- * Clients can extend abstract implementations of IChannel: AbstractChannel or StreamChannel.
- */
-
-public interface IChannel {
-
- /**
- * Channel state IDs
- */
- static final int
- STATE_OPENNING = 0,
- STATE_OPEN = 1,
- STATE_CLOSED = 2;
-
- /**
- * @return channel state, see STATE_*
- */
- int getState();
-
- /**
- * Send command message to remote peer for execution. Commands can be queued
- * locally before transmission. Sending commands too fast can fill up
- * communication channel buffers. Calling thread will be blocked until
- * enough buffer space is freed up by transmitting pending messages.
- * @param service - a remote service that will be sent the command
- * @param name - command name
- * @param args - command arguments encoded into array of bytes
- * @param done - call back object
- * @return pending command handle
- */
- IToken sendCommand(IService service, String name, byte[] args, ICommandListener done);
-
- /**
- * Command listener interface. Clients implement this interface to
- * receive command results.
- */
- interface ICommandListener {
-
- /**
- * Called when progress message (intermediate result) is received
- * from remote peer.
- * @param token - command handle
- * @param data - progress message arguments encoded into array of bytes
- */
- void progress(IToken token, byte[] data);
-
- /**
- * Called when command result received from remote peer.
- * @param token - command handle
- * @param data - command result message arguments encoded into array of bytes
- */
- void result(IToken token, byte[] data);
-
- /**
- * Called when command is terminated because communication channel was closed or
- * command is not recognized by remote peer.
- * @param token - command handle
- * @param error - exception that forced the channel to close
- */
- void terminated(IToken token, Exception error);
- }
-
- /**
- * Send result message to remote peer. Messages can be queued locally before
- * transmission. Sending messages too fast can fill up communication channel
- * buffers. Calling thread will be blocked until enough buffer space is
- * freed up by transmitting pending messages.
- * @param token - command handle
- * @param results - result message arguments encoded into array of bytes
- */
- void sendResult(IToken token, byte[] results);
-
- /**
- * Reject a command by sending "N" result message to remote peer.
- * Clients should reject commands that they don't recognize.
- * Messages can be queued locally before
- * transmission. Sending messages too fast can fill up communication channel
- * buffers. Calling thread will be blocked until enough buffer space is
- * freed up by transmitting pending messages.
- * @param token - command handle
- * @param results - result message arguments encoded into array of bytes
- */
- void rejectCommand(IToken token);
-
- /**
- * Get current level of out-bound traffic congestion.
- *
- * @return integer value in range –100..100, where –100 means no pending
- * messages (no traffic), 0 means optimal load, and positive numbers
- * indicate level of congestion.
- *
- * Note: in-bound traffic congestion is detected by framework and reported to
- * remote peer without client needed to be involved. Clients willing to provide
- * additional data about local congestion should register itself using
- * Protocol.addCongestionMonitor().
- */
- int getCongestion();
-
- /**
- * Channel listener interface.
- */
- interface IChannelListener {
-
- /**
- * Called when a channel is opened or redirected.
- */
- void onChannelOpened();
-
- /**
- * Called when channel closed. If it is closed because of an error,
- * ‘error’ parameter will describe the error. ‘error’ is null if channel
- * is closed normally by calling Channel.close().
- * @param error - channel exception or null
- */
- void onChannelClosed(Throwable error);
-
- /**
- * Notifies listeners about channel out-bound traffic congestion level changes.
- * When level > 0 client should delay sending more messages.
- * @param level - current congestion level
- */
- void congestionLevel(int level);
- }
-
- /**
- * Subscribe a channel listener. The listener will be notified about changes of
- * channel state and changes of out-bound traffic congestion level.
- * @param listener - channel listener implementation
- */
- void addChannelListener(IChannelListener listener);
-
- /**
- * Remove a channel listener.
- * @param listener - channel listener implementation
- */
- void removeChannelListener(IChannelListener listener);
-
- /**
- * Command server interface.
- * This interface is to be implemented by service providers.
- */
- interface ICommandServer {
-
- /**
- * Called every time a command is received from remote peer.
- * @param token - command handle
- * @param name - command name
- * @param data - command arguments encoded into array of bytes
- */
- void command(IToken token, String name, byte[] data);
- }
-
- /**
- * Subscribe a command server. The server will be notified about command
- * messages received through this channel for given service.
- * @param service - local service implementation
- * @param server - implementation of service commands listener
- */
- void addCommandServer(IService service, ICommandServer server);
-
- /**
- * Remove a command server.
- * @param service - local service implementation
- * @param server - implementation of service commands listener
- */
- void removeCommandServer(IService service, ICommandServer server);
-
- /**
- * A generic interface for service event listener.
- * Services usually define a service specific event listener interface,
- * which is implemented using this generic listener.
- * Clients should user service specific listener interface,
- * unless no such interface is defined.
- */
- interface IEventListener {
- /**
- * Called when service event message is received
- * @param name - event name
- * @param data - event arguments encode as array of bytes
- */
- void event(String name, byte[] data);
- }
-
- /**
- * Subscribe an event listener for given service.
- * @param service - remote service proxy
- * @param server - implementation of service event listener
- */
- void addEventListener(IService service, IEventListener listener);
-
- /**
- * Unsubscribe an event listener for given service.
- * @param service - remote service proxy
- * @param server - implementation of service event listener
- */
- void removeEventListener(IService service, IEventListener listener);
-
- /**
- * @return IPeer object representing local endpoint of communication channel.
- */
- IPeer getLocalPeer();
-
- /**
- * @return IPeer object representing remote endpoint of communication channel.
- */
- IPeer getRemotePeer();
-
- /**
- * @return collection of services available on local peer.
- */
- Collection<String> getLocalServices();
-
- /**
- * @return an object representing a service from local peer.
- * Return null if the service is not available.
- */
- IService getLocalService(String service_name);
-
- /**
- * @return an object representing a service from local peer.
- * Service object should implement given interface.
- * Return null if implementation of the interface is not available.
- */
- <V extends IService> V getLocalService(Class<V> service_interface);
-
- /**
- * @return collection of services available on remote peer.
- */
- Collection<String> getRemoteServices();
-
- /**
- * Get a proxy for remote service.
- * @param service_name - remote service name
- * @return an object (proxy) representing a service from remote peer.
- * Return null if the service is not available.
- * Return an instance of GenericProxy if 'service_name' is not a standard TCF service.
- */
- IService getRemoteService(String service_name);
-
- /**
- * Get a proxy for remote service.
- * @param service_interface - service interface class
- * @return an object (proxy) representing a service from remote peer,
- * which implements given interface.
- * Return null if implementation of the interface is not available.
- */
- <V extends IService> V getRemoteService(Class<V> service_interface);
-
- /**
- * Install a service proxy object on this channel.
- * This method can be called only from channel open call-back.
- * It allows a client to extend TCF by adding proxy objects for non-standard services.
- * Client, wishing to become service proxy provider, should register itself
- * using either Protocol.addChannelOpenListener() or IChannel.addChannelListener().
- * It is not allowed to install more then one proxy for a given service interface on
- * a particular channel.
- * @param service_interface - service interface class
- * @param service_proxy - service proxy object
- */
- <V extends IService> void setServiceProxy(Class<V> service_interface, IService service_proxy);
-
- /**
- * Close communication channel.
- */
- void close();
-
- /**
- * Close channel in case of communication error.
- * @param error - cause of channel termination
- */
- void terminate(Throwable error);
-
- /**
- * Redirect this channel to given peer using this channel remote peer locator service as a proxy.
- * @param peer_id - peer that will become new remote communication endpoint of this channel
- */
- void redirect(String peer_id);
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IErrorReport.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IErrorReport.java
deleted file mode 100644
index 86b85a1f9..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IErrorReport.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.tm.tcf.protocol;
-
-import java.util.Map;
-
-/**
- * This interface defines TCF standard format of error reports.
- *
- * Exception objects can implement this interface to make error report details
- * available for clients.
- *
- * Usage example:
- *
- * Exception x = ...
- * if (x instanceof IErrorReport) {
- * int error_code = ((IErrorReport)x).getErrorCode();
- * ...
- *
- * @noextend This interface is not intended to be extended by clients.
- */
-public interface IErrorReport {
-
- /** Error report attribute names */
- public static final String
- ERROR_CODE = "Code", // integer
- ERROR_TIME = "Time", // integer
- ERROR_SERVICE = "Service", // string
- ERROR_FORMAT = "Format", // string
- ERROR_PARAMS = "Params", // array
- ERROR_SEVERITY = "Severity", // integer
- ERROR_ALT_CODE = "AltCode", // integer
- ERROR_ALT_ORG = "AltOrg", // string
- ERROR_CAUSED_BY = "CausedBy"; // object
-
- /** Error severity codes */
- public static final int
- SEVERITY_ERROR = 0,
- SEVERITY_WARNING = 1,
- SEVERITY_FATAL = 2;
-
- /** Error code ranges */
- public static final int
- /** Standard TCF code range */
- CODE_STD_MIN = 0,
- CODE_STD_MAX = 0xffff,
-
- /** Service specific codes. Decoding requires service ID. */
- CODE_SERVICE_SPECIFIC_MIN = 0x10000,
- CODE_SERVICE_SPECIFIC_MAX = 0x1ffff,
-
- /** Reserved codes - will never be used by the TCF standard */
- CODE_RESERVED_MIN = 0x20000,
- CODE_RESERVED_MAX = 0x2ffff;
-
- /** Standard TCF error codes */
- public static final int
- TCF_ERROR_OTHER = 1,
- TCF_ERROR_JSON_SYNTAX = 2,
- TCF_ERROR_PROTOCOL = 3,
- TCF_ERROR_BUFFER_OVERFLOW = 4,
- TCF_ERROR_CHANNEL_CLOSED = 5,
- TCF_ERROR_COMMAND_CANCELLED = 6,
- TCF_ERROR_UNKNOWN_PEER = 7,
- TCF_ERROR_BASE64 = 8,
- TCF_ERROR_EOF = 9,
- TCF_ERROR_ALREADY_STOPPED = 10,
- TCF_ERROR_ALREADY_EXITED = 11,
- TCF_ERROR_ALREADY_RUNNING = 12,
- TCF_ERROR_ALREADY_ATTACHED = 13,
- TCF_ERROR_IS_RUNNING = 14,
- TCF_ERROR_INV_DATA_SIZE = 15,
- TCF_ERROR_INV_CONTEXT = 16,
- TCF_ERROR_INV_ADDRESS = 17,
- TCF_ERROR_INV_EXPRESSION = 18,
- TCF_ERROR_INV_FORMAT = 19,
- TCF_ERROR_INV_NUMBER = 20,
- TCF_ERROR_INV_DWARF = 21,
- TCF_ERROR_SYM_NOT_FOUND = 22,
- TCF_ERROR_UNSUPPORTED = 23,
- TCF_ERROR_INV_DATA_TYPE = 24,
- TCF_ERROR_INV_COMMAND = 25;
-
- public int getErrorCode();
-
- public int getAltCode();
-
- public String getAltOrg();
-
- public Map<String,Object> getAttributes();
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IEventQueue.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IEventQueue.java
deleted file mode 100644
index 15da38e28..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IEventQueue.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.protocol;
-
-/**
- * Clients of stand-alone version the framework should implement this interface and call Protocol.setEventQueue.
- * Eclipse based clients don't need to implement IEventQueue since the implementation is provide by TCF bundle activator.
- *
- * Implementation should encapsulate a queue and asynchronous event dispatch machinery, which
- * extracts events from the queue and dispatches them by calling event's run() method.
- * The implementation is used by framework to queue and dispatch all events.
- */
-public interface IEventQueue {
-
- /**
- * Causes <code>runnable</code> to have its <code>run</code>
- * method called in the dispatch thread of this event queue.
- * Events are dispatched in same order as queued.
- *
- * @param runnable the <code>Runnable</code> whose <code>run</code>
- * method should be executed asynchronously.
- */
- void invokeLater(Runnable runnable);
-
- /**
- * Returns true if the calling thread is this event queue's dispatch thread.
- * Use this call the ensure that a given task is being executed (or not being) on dispatch thread.
- *
- * @return true if running on the dispatch thread.
- */
- boolean isDispatchThread();
-
- /**
- * Get current level of queue congestion.
- *
- * @return integer value in range –100..100, where –100 means no pending
- * messages (no traffic), 0 means optimal load, and positive numbers
- * indicate level of congestion.
- */
- int getCongestion();
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/ILogger.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/ILogger.java
deleted file mode 100644
index b2f869a64..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/ILogger.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.tm.tcf.protocol;
-
-/**
- * Clients of stand-alone version the framework should implement this interface and call Protocol.setLogger.
- * Eclipse based clients don't need to implement ILogger since the implementation is provide by TCF bundle activator.
- */
-public interface ILogger {
-
- /**
- * Add an entry into a log.
- *
- * This method can be invoked from any thread.
- *
- * @param msg - log entry text.
- * @param x - a Java exception associated with the log entry or null.
- */
- void log(String msg, Throwable x);
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IPeer.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IPeer.java
deleted file mode 100644
index 3f96d298a..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IPeer.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.protocol;
-
-import java.util.Map;
-
-/**
- * Both hosts and targets are represented by objects
- * implementing IPeer interface. A peer can act as host or
- * target depending on services it implements.
- * List of currently known peers can be retrieved by
- * calling ILocator.getPeers()
- *
- * @noimplement This interface is not intended to be implemented by clients.
- * Client can extends the abstract IPeer implementation: AbstractPeer.
- */
-public interface IPeer {
-
- /**
- * Peer property names. Implementation can define additional properties.
- */
- static final String
- ATTR_ID = "ID",
- ATTR_NAME = "Name",
- ATTR_OS_NAME = "OSName",
- ATTR_TRANSPORT_NAME = "TransportName",
- ATTR_PROXY = "Proxy",
- ATTR_IP_HOST = "Host",
- ATTR_IP_ALIASES = "Aliases",
- ATTR_IP_ADDRESSES = "Addresses",
- ATTR_IP_PORT = "Port";
-
-
- /**
- * @return map of peer attributes
- */
- Map<String, String> getAttributes();
-
- /**
- * @return peer unique ID, same as getAttributes().get(ATTR_ID)
- */
- String getID();
-
- /**
- * @return peer name, same as getAttributes().get(ATTR_NAME)
- */
- String getName();
-
- /**
- * Same as getAttributes().get(ATTR_OS_NAME)
- */
- String getOSName();
-
- /**
- * Same as getAttributes().get(ATTR_TRANSPORT_NAME)
- */
- String getTransportName();
-
- /**
- * Open channel to communicate with this peer.
- * Note: the channel is not fully open yet when this method returns.
- * It’s state is IChannel.STATE_OPENNING.
- * Protocol.Listener will be called when the channel will be opened or closed.
- */
- IChannel openChannel();
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IService.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IService.java
deleted file mode 100644
index 583d41039..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IService.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.protocol;
-
-/**
- * Base interface for all service interfaces. A client can get list of available services
- * by calling IChannel.getLocalServices() and IChannel.getRemoteServices().
- *
- * Remote services are represented by a proxy objects that implement service interfaces by
- * translating method calls to TCF messages and sending them to a remote peer.
- * When communication channel is open, TCF automatically creates proxies for standard services.
- * TCF clients can provides addition proxies for non-standard services by calling IChannel.setServiceProxy().
- */
-
-public interface IService {
-
- /**
- * Get unique name of this service.
- * @return service name.
- */
- String getName();
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IServiceProvider.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IServiceProvider.java
deleted file mode 100644
index fe9457f4a..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IServiceProvider.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Anyware Technologies 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:
- * Anyware Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.tcf.protocol;
-
-/**
- * Clients can implement this interface if they want to provide implementation of a local service or
- * remote service proxy.
- */
-public interface IServiceProvider {
-
- public IService[] getLocalService(IChannel channel);
-
- public IService getServiceProxy(IChannel channel, String service_name);
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IToken.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IToken.java
deleted file mode 100644
index e03f7ed7d..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/IToken.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.protocol;
-
-/**
- * IToken is created by the framework for each command sent to a remote peer.
- * It is used to match results to commands and to cancel pending commands.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface IToken {
-
- /**
- * Try to cancel a command associated with given token. A command can be
- * canceled by this method only if it was not transmitted yet to remote peer
- * for execution. Successfully canceled command does not produce any result
- * messages.
- *
- * @return true if successful.
- */
- boolean cancel();
-
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/ITransportProvider.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/ITransportProvider.java
deleted file mode 100644
index c8a7a8187..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/ITransportProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.tm.tcf.protocol;
-
-/**
- * ITransportProvider represents communication protocol that can be used to open TCF communication channels.
- * Examples of transports are: TCP/IP, RS-232, USB.
- *
- * Client can implement this interface if they want to provide support for a transport that is not
- * supported directly by the framework.
- */
-public interface ITransportProvider {
-
- /**
- * Return transport name. Same as used as peer attribute, @see IPeer.ATTR_TRANSPORT_NAME
- * @return transport name.
- */
- String getName();
-
- /**
- * Open channel to communicate with this peer using this transport.
- * Note: the channel can be not fully open yet when this method returns.
- * It’s state can be IChannel.STATE_OPENNING.
- * Protocol.Listener will be called when the channel will be opened or closed.
- * @param peer - a IPeer object that describes remote end-point of the channel.
- * @return TCF communication channel.
- */
- IChannel openChannel(IPeer peer);
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/JSON.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/JSON.java
deleted file mode 100644
index 0b4f1f51b..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/JSON.java
+++ /dev/null
@@ -1,613 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.protocol;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * JSON is TCF preferred marshaling. This class implements generation and parsing of JSON strings.
- * The code is optimized for speed since it is a time-critical part of the framework.
- *
- * Reading of JSON produces data structure that consists of objects of these classes:
- * Boolean, Number, String, Collection, Map.
- *
- * Writing of JSON is supported for:
- * Boolean, Number, String, char[], byte[], Object[], Collection, Map
- *
- * Clients can enable writing support for objects of a other classes by
- * registering ObjectWriter interface implementation.
- *
- * @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public final class JSON {
-
- /**
- * Clients implement ObjectWriter interface when they want to enable marshaling of
- * object classes that are not directly supported by JSON library.
- */
- public interface ObjectWriter {
- void write(Object o) throws IOException;
- }
-
- private static final Map<Class<?>,ObjectWriter> object_writers = new HashMap<Class<?>,ObjectWriter>();
-
- private static char[] tmp_buf = new char[0x1000];
- private static byte[] tmp_bbf = new byte[0x1000];
- private static int tmp_buf_pos;
-
- private static Reader reader;
- private static final char[] cur_buf = new char[0x1000];
- private static int cur_buf_pos;
- private static int cur_buf_len;
- private static int cur_ch;
-
- // This buffer is used to create nice error reports
- private static final char[] err_buf = new char[100];
- private static int err_buf_pos;
- private static int err_buf_cnt;
-
- /**
- * Add a handler for converting objects of a particular class into JSON.
- * @param cls - a class
- * @param writer - ObjectWriter implementation that provides generation of JSON for a given class.
- */
- public static void addObjectWriter(Class<?> cls, ObjectWriter writer) {
- object_writers.put(cls, writer);
- }
-
- /**
- * Write a character into JSON output buffer.
- * Clients should not call this method directly, except from ObjectWriter implementation.
- * @param ch
- */
- public static void write(char ch) {
- if (tmp_buf_pos >= tmp_buf.length) {
- char[] tmp = new char[tmp_buf.length * 2];
- System.arraycopy(tmp_buf, 0, tmp, 0, tmp_buf_pos);
- tmp_buf = tmp;
- }
- tmp_buf[tmp_buf_pos++] = ch;
- }
-
- /**
- * Write a string into JSON output buffer.
- * The string is written "as-is". Call writeObject() to convert a String into JSON string.
- * Clients should not call this method directly, except from ObjectWriter implementation.
- * @param s - a string
- */
- public static void write(String s) {
- int l = s.length();
- for (int i = 0; i < l; i++) {
- char ch = s.charAt(i);
- if (tmp_buf_pos >= tmp_buf.length) write(ch);
- else tmp_buf[tmp_buf_pos++] = ch;
- }
- }
-
- /**
- * Write a non-negative integer number into JSON output buffer.
- * Clients should not call this method directly, except from ObjectWriter implementation.
- * @param n - a number
- */
- public static void writeUInt(int n) {
- assert n >= 0;
- if (n >= 10) writeUInt(n / 10);
- write((char)('0' + n % 10));
- }
-
- private static void read() throws IOException {
- if (cur_buf_pos >= cur_buf_len) {
- cur_buf_len = reader.read(cur_buf);
- cur_buf_pos = 0;
- if (cur_buf_len < 0) {
- cur_buf_len = 0;
- cur_ch = -1;
- return;
- }
- }
- cur_ch = cur_buf[cur_buf_pos++];
- err_buf[err_buf_pos++] = (char)cur_ch;
- if (err_buf_pos >= err_buf.length) {
- err_buf_pos = 0;
- err_buf_cnt++;
- }
- }
-
- private static void error() throws IOException {
- error("syntax error");
- }
-
- private static void error(String msg) throws IOException {
- StringBuffer bf = new StringBuffer();
- bf.append("JSON " + msg + ":");
- int cnt = 0;
- boolean nl = true;
- for (int i = 0;; i++) {
- char ch = 0;
- if (err_buf_cnt == 0 && i < err_buf_pos) {
- ch = err_buf[i];
- }
- else if (err_buf_cnt > 0 && i < err_buf.length) {
- ch = err_buf[(err_buf_pos + i) % err_buf.length];
- }
- else {
- int n = reader.read();
- if (n < 0) break;
- ch = (char)n;
- }
- if (nl) {
- bf.append("\n ");
- if (err_buf_cnt == 0) bf.append(cnt);
- else bf.append('*');
- bf.append(": ");
- if (cnt == 0 && err_buf_cnt > 0) bf.append("...");
- nl = false;
- }
- if (ch == 0) {
- cnt++;
- nl = true;
- continue;
- }
- bf.append(ch);
- }
- throw new IOException(bf.toString());
- }
-
- private static int readHexDigit() throws IOException {
- int n = 0;
- if (cur_ch >= '0' && cur_ch <= '9') n = cur_ch - '0';
- else if (cur_ch >= 'A' && cur_ch <= 'F') n = cur_ch - 'A' + 10;
- else if (cur_ch >= 'a' && cur_ch <= 'f') n = cur_ch - 'a' + 10;
- else error();
- read();
- return n;
- }
-
- private static Object readFloat(boolean sign, BigInteger val) throws IOException {
- int scale = 0;
- int fraction = 0;
- if (cur_ch == '.') {
- read();
- while (cur_ch >= '0' && cur_ch <= '9') {
- val = val.multiply(BigInteger.valueOf(10));
- val = val.add(BigInteger.valueOf(cur_ch - '0'));
- fraction++;
- read();
- }
- }
- if (cur_ch == 'E' || cur_ch == 'e') {
- read();
- boolean neg = cur_ch == '-';
- if (neg || cur_ch == '+') read();
- while (cur_ch >= '0' && cur_ch <= '9') {
- scale = scale * 10 + cur_ch - '0';
- read();
- }
- if (neg) scale = -scale;
- }
- if (sign) val = val.negate();
- return new BigDecimal(val, fraction - scale);
- }
-
- private static Object readNestedObject() throws IOException {
- switch (cur_ch) {
- case '"':
- read();
- tmp_buf_pos = 0;
- for (;;) {
- if (cur_ch <= 0) error();
- if (cur_ch == '"') break;
- if (cur_ch == '\\') {
- read();
- if (cur_ch <= 0) error();
- switch (cur_ch) {
- case '"':
- case '\\':
- case '/':
- break;
- case 'b':
- cur_ch = '\b';
- break;
- case 'f':
- cur_ch = '\f';
- break;
- case 'n':
- cur_ch = '\n';
- break;
- case 'r':
- cur_ch = '\r';
- break;
- case 't':
- cur_ch = '\t';
- break;
- case 'u':
- read();
- int n = 0;
- n |= readHexDigit() << 12;
- n |= readHexDigit() << 8;
- n |= readHexDigit() << 4;
- n |= readHexDigit();
- write((char)n);
- continue;
- default:
- error();
- break;
- }
- }
- if (tmp_buf_pos >= tmp_buf.length) {
- write((char)cur_ch);
- }
- else {
- tmp_buf[tmp_buf_pos++] = (char)cur_ch;
- }
- if (cur_buf_pos >= cur_buf_len) {
- read();
- }
- else {
- cur_ch = cur_buf[cur_buf_pos++];
- err_buf[err_buf_pos++] = (char)cur_ch;
- if (err_buf_pos >= err_buf.length) {
- err_buf_pos = 0;
- err_buf_cnt++;
- }
- }
- }
- read();
- return new String(tmp_buf, 0, tmp_buf_pos);
- case '[':
- List<Object> l = new ArrayList<Object>();
- read();
- if (cur_ch <= 0) error();
- if (cur_ch != ']') {
- for (;;) {
- l.add(readNestedObject());
- if (cur_ch == ']') break;
- if (cur_ch != ',') error();
- read();
- }
- }
- read();
- return Collections.unmodifiableList(l);
- case '{':
- Map<String,Object> m = new HashMap<String,Object>();
- read();
- if (cur_ch <= 0) error();
- if (cur_ch != '}') {
- for (;;) {
- String key = (String)readNestedObject();
- if (cur_ch != ':') error();
- read();
- Object val = readNestedObject();
- m.put(key, val);
- if (cur_ch == '}') break;
- if (cur_ch != ',') error();
- read();
- }
- }
- read();
- return Collections.unmodifiableMap(m);
- case 'n':
- read();
- if (cur_ch != 'u') error();
- read();
- if (cur_ch != 'l') error();
- read();
- if (cur_ch != 'l') error();
- read();
- return null;
- case 'f':
- read();
- if (cur_ch != 'a') error();
- read();
- if (cur_ch != 'l') error();
- read();
- if (cur_ch != 's') error();
- read();
- if (cur_ch != 'e') error();
- read();
- return Boolean.FALSE;
- case 't':
- read();
- if (cur_ch != 'r') error();
- read();
- if (cur_ch != 'u') error();
- read();
- if (cur_ch != 'e') error();
- read();
- return Boolean.TRUE;
- default:
- boolean neg = cur_ch == '-';
- if (neg) read();
- if (cur_ch >= '0' && cur_ch <= '9') {
- int v = 0;
- while (v <= 0x7fffffff / 10 - 1) {
- v = v * 10 + (cur_ch - '0');
- read();
- if (cur_ch < '0' || cur_ch > '9') {
- if (cur_ch == '.' || cur_ch == 'E' || cur_ch == 'e') {
- return readFloat(neg, BigInteger.valueOf(v));
- }
- if (neg) v = -v;
- return Integer.valueOf(v);
- }
- }
- long vl = v;
- while (vl < 0x7fffffffffffffffl / 10 - 1) {
- vl = vl * 10 + (cur_ch - '0');
- read();
- if (cur_ch < '0' || cur_ch > '9') {
- if (cur_ch == '.' || cur_ch == 'E' || cur_ch == 'e') {
- return readFloat(neg, BigInteger.valueOf(vl));
- }
- if (neg) vl = -vl;
- return Long.valueOf(vl);
- }
- }
- StringBuffer sb = new StringBuffer();
- sb.append(vl);
- while (true) {
- sb.append(cur_ch);
- read();
- if (cur_ch < '0' || cur_ch > '9') {
- BigInteger n = new BigInteger(sb.toString());
- if (cur_ch == '.' || cur_ch == 'E' || cur_ch == 'e') {
- return readFloat(neg, n);
- }
- if (neg) n = n.negate();
- return n;
- }
- }
- }
- error();
- return null;
- }
- }
-
- private static Object readObject() throws IOException {
- Object o = readNestedObject();
- if (cur_ch >= 0) error();
- return o;
- }
-
- private static Object[] readSequence() throws IOException {
- List<Object> l = new ArrayList<Object>();
- while (cur_ch >= 0) {
- if (cur_ch == 0) l.add(null);
- else l.add(readNestedObject());
- if (cur_ch != 0) error("missing \\0 terminator");
- read();
- }
- return l.toArray();
- }
-
- /**
- * Write an object into JSON output buffer.
- * Clients should not call this method directly, except from ObjectWriter implementation.
- * @param o - an object to write
- */
- @SuppressWarnings("unchecked")
- public static void writeObject(Object o) throws IOException {
- if (o == null) {
- write("null");
- }
- else if (o instanceof Boolean) {
- write(o.toString());
- }
- else if (o instanceof Number) {
- write(o.toString());
- }
- else if (o instanceof String) {
- String s = (String)o;
- char[] arr = new char[s.length()];
- s.getChars(0, arr.length, arr, 0);
- writeObject(arr);
- }
- else if (o instanceof char[]) {
- char[] s = (char[])o;
- write('"');
- int l = s.length;
- for (int i = 0; i < l; i++) {
- char ch = s[i];
- switch (ch) {
- case 0:
- write("\\u0000");
- break;
- case '\r':
- write("\\r");
- break;
- case '\n':
- write("\\n");
- break;
- case '\t':
- write("\\t");
- break;
- case '\b':
- write("\\b");
- break;
- case '\f':
- write("\\f");
- break;
- case '"':
- case '\\':
- write('\\');
- default:
- if (tmp_buf_pos >= tmp_buf.length) write(ch);
- else tmp_buf[tmp_buf_pos++] = ch;
- }
- }
- write('"');
- }
- else if (o instanceof byte[]) {
- write('[');
- byte[] arr = (byte[])o;
- boolean comma = false;
- for (int i = 0; i < arr.length; i++) {
- if (comma) write(',');
- writeUInt(arr[i] & 0xff);
- comma = true;
- }
- write(']');
- }
- else if (o instanceof Object[]) {
- write('[');
- Object[] arr = (Object[])o;
- boolean comma = false;
- for (int i = 0; i < arr.length; i++) {
- if (comma) write(',');
- writeObject(arr[i]);
- comma = true;
- }
- write(']');
- }
- else if (o instanceof Collection) {
- write('[');
- boolean comma = false;
- for (Iterator<Object> i = ((Collection<Object>)o).iterator(); i.hasNext();) {
- if (comma) write(',');
- writeObject(i.next());
- comma = true;
- }
- write(']');
- }
- else if (o instanceof Map) {
- Map<String,Object> map = (Map<String,Object>)o;
- write('{');
- boolean comma = false;
- for (Iterator<Map.Entry<String,Object>> i = map.entrySet().iterator(); i.hasNext();) {
- if (comma) write(',');
- Map.Entry<String,Object> e = i.next();
- writeObject(e.getKey());
- write(':');
- writeObject(e.getValue());
- comma = true;
- }
- write('}');
- }
- else {
- ObjectWriter writer = object_writers.get(o.getClass());
- if (writer != null) {
- writer.write(o);
- }
- else {
- throw new IOException("JSON: unsupported object type");
- }
- }
- }
-
- private static byte[] toBytes() {
- int inp_pos = 0;
- int out_pos = 0;
- while (inp_pos < tmp_buf_pos) {
- if (out_pos >= tmp_bbf.length - 4) {
- byte[] tmp = new byte[tmp_bbf.length * 2];
- System.arraycopy(tmp_bbf, 0, tmp, 0, out_pos);
- tmp_bbf = tmp;
- }
- int ch = tmp_buf[inp_pos++];
- if (ch < 0x80) {
- tmp_bbf[out_pos++] = (byte)ch;
- }
- else if (ch < 0x800) {
- tmp_bbf[out_pos++] = (byte)((ch >> 6) | 0xc0);
- tmp_bbf[out_pos++] = (byte)(ch & 0x3f | 0x80);
- }
- else if (ch < 0x10000) {
- tmp_bbf[out_pos++] = (byte)((ch >> 12) | 0xe0);
- tmp_bbf[out_pos++] = (byte)((ch >> 6) & 0x3f | 0x80);
- tmp_bbf[out_pos++] = (byte)(ch & 0x3f | 0x80);
- }
- else {
- tmp_bbf[out_pos++] = (byte)((ch >> 18) | 0xf0);
- tmp_bbf[out_pos++] = (byte)((ch >> 12) & 0x3f | 0x80);
- tmp_bbf[out_pos++] = (byte)((ch >> 6) & 0x3f | 0x80);
- tmp_bbf[out_pos++] = (byte)(ch & 0x3f | 0x80);
- }
- }
- byte[] res = new byte[out_pos];
- System.arraycopy(tmp_bbf, 0, res, 0, out_pos);
- return res;
- }
-
- public static String toJSON(Object o) throws IOException {
- assert Protocol.isDispatchThread();
- tmp_buf_pos = 0;
- writeObject(o);
- return new String(tmp_buf, 0, tmp_buf_pos);
- }
-
- public static byte[] toJASONBytes(Object o) throws IOException {
- assert Protocol.isDispatchThread();
- tmp_buf_pos = 0;
- writeObject(o);
- return toBytes();
- }
-
- public static byte[] toJSONSequence(Object[] o) throws IOException {
- assert Protocol.isDispatchThread();
- if (o == null || o.length == 0) return null;
- tmp_buf_pos = 0;
- for (int i = 0; i < o.length; i++) {
- writeObject(o[i]);
- write((char)0);
- }
- return toBytes();
- }
-
- public static Object parseOne(String s) throws IOException {
- assert Protocol.isDispatchThread();
- if (s.length() == 0) return null;
- reader = new StringReader(s);
- err_buf_pos = 0;
- err_buf_cnt = 0;
- cur_buf_pos = 0;
- cur_buf_len = 0;
- read();
- return readObject();
- }
-
- public static Object parseOne(byte[] b) throws IOException {
- assert Protocol.isDispatchThread();
- if (b.length == 0) return null;
- reader = new InputStreamReader(new ByteArrayInputStream(b), "UTF8");
- err_buf_pos = 0;
- err_buf_cnt = 0;
- cur_buf_pos = 0;
- cur_buf_len = 0;
- read();
- return readObject();
- }
-
- public static Object[] parseSequence(byte[] b) throws IOException {
- assert Protocol.isDispatchThread();
- reader = new InputStreamReader(new ByteArrayInputStream(b), "UTF8");
- err_buf_pos = 0;
- err_buf_cnt = 0;
- cur_buf_pos = 0;
- cur_buf_len = 0;
- read();
- return readSequence();
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/Protocol.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/Protocol.java
deleted file mode 100644
index d5127384c..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/protocol/Protocol.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.protocol;
-
-import java.util.ArrayList;
-import java.util.TreeSet;
-
-import org.eclipse.tm.internal.tcf.core.LocalPeer;
-import org.eclipse.tm.internal.tcf.core.ServiceManager;
-import org.eclipse.tm.internal.tcf.core.TransportManager;
-import org.eclipse.tm.internal.tcf.services.local.LocatorService;
-import org.eclipse.tm.tcf.services.ILocator;
-
-
-/**
- * Class Protocol provides static methods to access Target Communication Framework root objects:
- * 1. the framework event queue and dispatch thread;
- * 2. local instance of Locator service, which maintains a list of available targets;
- * 3. list of open communication channels.
- *
- * It also provides utility methods for posting asynchronous events,
- * including delayed events (timers).
- *
- * Before TCF can be used, it should be given an object implementing IEventQueue interface:
- * @see #setEventQueue
- *
- * @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public final class Protocol {
-
- private static IEventQueue event_queue;
- private static ILogger logger;
- private static final TreeSet<Timer> timer_queue = new TreeSet<Timer>();
- private static int timer_cnt;
-
- private static class Timer implements Comparable<Timer>{
- final int id;
- final long time;
- final Runnable run;
-
- Timer(long time, Runnable run) {
- this.id = timer_cnt++;
- this.time = time;
- this.run = run;
- }
-
- public int compareTo(Timer x) {
- if (x == this) return 0;
- if (time < x.time) return -1;
- if (time > x.time) return +1;
- if (id < x.id) return -1;
- if (id > x.id) return +1;
- assert false;
- return 0;
- }
- }
-
- private static final Thread timer_dispatcher = new Thread() {
- public void run() {
- try {
- synchronized (timer_queue) {
- while (true) {
- if (timer_queue.isEmpty()) {
- timer_queue.wait();
- }
- else {
- long time = System.currentTimeMillis();
- Timer t = timer_queue.first();
- if (t.time > time) {
- timer_queue.wait(t.time - time);
- }
- else {
- timer_queue.remove(t);
- invokeLater(t.run);
- }
- }
- }
- }
- }
- catch (IllegalStateException x) {
- // Dispatch is shut down, exit this thread
- }
- catch (Throwable x) {
- log("Exception in TCF dispatch loop", x);
- }
- }
- };
-
- private static final ArrayList<CongestionMonitor> congestion_monitors = new ArrayList<CongestionMonitor>();
-
- /**
- * Before TCF can be used, it should be given an object implementing IEventQueue interface.
- * The implementation maintains a queue of objects implementing Runnable interface and
- * executes <code>run</code> methods of that objects in a sequence by a single thread.
- * The thread in referred as TCF event dispatch thread. Objects in the queue are called TCF events.
- * Executing <code>run</code> method of an event is also called dispatching of the event.
- *
- * Only few methods in TCF APIs are thread safe - can be invoked from any thread.
- * If a method description does not say "can be invoked from any thread" explicitly -
- * the method must be invoked from TCF event dispatch thread. All TCF listeners are
- * invoked from the dispatch thread.
- *
- * @param event_queue - IEventQueue implementation.
- */
- public static void setEventQueue(IEventQueue event_queue) {
- assert Protocol.event_queue == null;
- Protocol.event_queue = event_queue;
- event_queue.invokeLater(new Runnable() {
-
- public void run() {
- new LocatorService();
- new LocalPeer();
- }
- });
- timer_dispatcher.setName("TCF Timer Dispatcher");
- timer_dispatcher.setDaemon(true);
- timer_dispatcher.start();
- }
-
- /**
- * @return instance of IEventQueue that is used for TCF events.
- */
- public static IEventQueue getEventQueue() {
- return event_queue;
- }
-
- /**
- * Returns true if the calling thread is TCF event dispatch thread.
- * Use this call the ensure that a given task is being executed (or not being)
- * on dispatch thread.
- *
- * @return true if running on the dispatch thread.
- */
- public static boolean isDispatchThread() {
- return event_queue != null && event_queue.isDispatchThread();
- }
-
- /**
- * Causes <code>runnable</code> event to have its <code>run</code>
- * method called in the dispatch thread of the framework.
- * Events are dispatched in same order as queued.
- * If invokeLater is called from the dispatching thread
- * the <i>runnable.run()</i> will still be deferred until
- * all pending events have been processed.
- *
- * This method can be invoked from any thread.
- *
- * @param runnable the <code>Runnable</code> whose <code>run</code>
- * method should be executed asynchronously.
- */
- public static void invokeLater(Runnable runnable) {
- event_queue.invokeLater(runnable);
- }
-
- /**
- * Causes <code>runnable</code> event to have its <code>run</code>
- * method called in the dispatch thread of the framework.
- * The event is dispatched after given delay.
- *
- * This method can be invoked from any thread.
- *
- * @param delay milliseconds to delay event dispatch.
- * If delay <= 0 the event is posted into the
- * "ready" queue without delay.
- * @param runnable the <code>Runnable</code> whose <code>run</code>
- * method should be executed asynchronously.
- */
- public static void invokeLater(long delay, Runnable runnable) {
- if (delay <= 0) {
- event_queue.invokeLater(runnable);
- }
- else {
- synchronized (timer_queue) {
- timer_queue.add(new Timer(System.currentTimeMillis() + delay, runnable));
- timer_queue.notify();
- }
- }
- }
-
- /**
- * Causes <code>runnable</code> to have its <code>run</code>
- * method called in the dispatch thread of the framework.
- * Calling thread is suspended until the method is executed.
- * If invokeAndWait is called from the dispatching thread
- * the <i>runnable.run()</i> is executed immediately.
- *
- * This method can be invoked from any thread.
- *
- * @param runnable the <code>Runnable</code> whose <code>run</code>
- * method should be executed on dispatch thread.
- */
- public static void invokeAndWait(final Runnable runnable) {
- if (event_queue.isDispatchThread()) {
- runnable.run();
- }
- else {
- Runnable r = new Runnable() {
- public void run() {
- try {
- runnable.run();
- }
- finally {
- synchronized (this) {
- notify();
- }
- }
- }
- };
- synchronized (r) {
- event_queue.invokeLater(r);
- try {
- r.wait();
- }
- catch (InterruptedException x) {
- throw new Error(x);
- }
- }
- }
- }
-
- /**
- * Set framework logger.
- * By default Eclipse logger is used, or System.err if TCF is used stand-alone.
- *
- * @param logger - an object implementing ILogger interface.
- */
- public static synchronized void setLogger(ILogger logger) {
- Protocol.logger = logger;
- }
-
- /**
- * Logs the given message.
- * @see #setLogger
- * @param msg - log entry text
- * @param x - a Java exception associated with the log entry or null.
- */
- public static synchronized void log(String msg, Throwable x) {
- if (logger == null) {
- System.err.println(msg);
- x.printStackTrace();
- }
- else {
- logger.log(msg, x);
- }
- }
-
- /**
- * Get instance of the framework locator service.
- * The service can be used to discover available remote peers.
- *
- * @return instance of ILocator.
- */
- public static ILocator getLocator() {
- return LocatorService.getLocator();
- }
-
- /**
- * Return an array of all open channels.
- * @return an array of IChannel
- */
- public static IChannel[] getOpenChannels() {
- return TransportManager.getOpenChannels();
- }
-
- /**
- * Interface to be implemented by clients willing to be notified when
- * new TCF communication channel is opened.
- */
- public interface ChannelOpenListener {
- public void onChannelOpen(IChannel channel);
- }
-
- /**
- * Add a listener that will be notified when new channel is opened.
- * @param listener
- */
- public static void addChannelOpenListener(ChannelOpenListener listener) {
- TransportManager.addChanelOpenListener(listener);
- }
-
- /**
- * Remove channel opening listener.
- * @param listener
- */
- public static void removeChannelOpenListener(ChannelOpenListener listener) {
- TransportManager.removeChanelOpenListener(listener);
- }
-
- /**
- * Transmit TCF event message.
- * The message is sent to all open communication channels – broadcasted.
- */
- public static void sendEvent(String service_name, String event_name, byte[] data) {
- TransportManager.sendEvent(service_name, event_name, data);
- }
-
- /**
- * Call back after all TCF messages sent by this host up to this moment are delivered
- * to their intended target. This method is intended for synchronization of messages
- * across multiple channels.
- *
- * Note: Cross channel synchronization can reduce performance and throughput.
- * Most clients don't need cross channel synchronization and should not call this method.
- *
- * @param done will be executed by dispatch thread after pending communication
- * messages are delivered to corresponding targets.
- */
- public static void sync(Runnable done) {
- TransportManager.sync(done);
- }
-
- /**
- * Clients implement CongestionMonitor interface to monitor usage of local resources,
- * like, for example, display queue size - if the queue becomes too big, UI response time
- * can become too high, or it can crash all together because of OutOfMemory errors.
- * TCF flow control logic prevents such conditions by throttling traffic coming from remote peers.
- * Note: Local (in-bound traffic) congestion is detected by framework and reported to
- * remote peer without client needed to be involved. Only clients willing to provide
- * additional data about local congestion should implement CongestionMonitor and
- * register it using Protocol.addCongestionMonitor().
- */
- public interface CongestionMonitor {
- /**
- * Get current level of client resource utilization.
- * @return integer value in range –100..100, where –100 means all resources are free,
- * 0 means optimal load, and positive numbers indicate level of congestion.
- */
- int getCongestionLevel();
- }
-
- /**
- * Register a congestion monitor.
- * @param monitor - client implementation of CongestionMonitor interface
- */
- public static void addCongestionMonitor(CongestionMonitor monitor) {
- assert monitor != null;
- assert isDispatchThread();
- congestion_monitors.add(monitor);
- }
-
- /**
- * Unregister a congestion monitor.
- * @param monitor - client implementation of CongestionMonitor interface
- */
- public static void removeCongestionMonitor(CongestionMonitor monitor) {
- assert isDispatchThread();
- congestion_monitors.remove(monitor);
- }
-
- /**
- * Get current level of local traffic congestion.
- *
- * @return integer value in range –100..100, where –100 means no pending
- * messages (no traffic), 0 means optimal load, and positive numbers
- * indicate level of congestion.
- */
- public static int getCongestionLevel() {
- assert isDispatchThread();
- int level = -100;
- for (CongestionMonitor m : congestion_monitors) {
- int n = m.getCongestionLevel();
- if (n > level) level = n;
- }
- if (event_queue != null) {
- int n = event_queue.getCongestion();
- if (n > level) level = n;
- }
- if (level > 100) level = 100;
- return level;
- }
-
- /**
- * Register s service provider.
- * @param provider - IServiceProvider implementation
- */
- public static void addServiceProvider(IServiceProvider provider){
- ServiceManager.addServiceProvider(provider);
- }
-
- /**
- * Unregister s service provider.
- * @param provider - IServiceProvider implementation
- */
- public static void removeServiceProvider(IServiceProvider provider){
- ServiceManager.removeServiceProvider(provider);
- }
-
- /**
- * Register s transport provider.
- * @param provider - ITransportProvider implementation
- */
- public static void addTransportProvider(ITransportProvider provider){
- TransportManager.addTransportProvider(provider);
- }
-
- /**
- * Unregister s transport provider.
- * @param provider - ITransportProvider implementation
- */
- public static void removeTransportProvider(ITransportProvider provider){
- TransportManager.removeTransportProvider(provider);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IBreakpoints.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IBreakpoints.java
deleted file mode 100644
index 9e40654bb..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IBreakpoints.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.services;
-
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-
-/**
- * Breakpoint is represented by unique identifier and set of properties.
- * Breakpoint identifier (String id) needs to be unique across all hosts and targets.
- *
- * Breakpoint properties (Map<String,Object>) is extendible collection of named attributes,
- * which define breakpoint location and behavior. This module defines some common
- * attribute names (see PROP_*), host tools and target agents may support additional attributes.
- *
- * For each breakpoint a target agent maintains another extendible collection of named attributes:
- * breakpoint status (Map<String,Object>, see STATUS_*). While breakpoint properties are
- * persistent and represent user input, breakpoint status reflects dynamic target agent reports
- * about breakpoint current state, like actual addresses where breakpoint is planted or planting errors.
- */
-public interface IBreakpoints extends IService {
-
- /**
- * Service name.
- */
- static final String NAME = "Breakpoints";
-
- /**
- * Breakpoint property names.
- */
- static final String
- PROP_ID = "ID", // String
- PROP_ENABLED = "Enabled", // Boolean
- PROP_TYPE = "BreakpointType", // String
- PROP_CONTEXTNAMES = "ContextNames", // Array
- PROP_CONTEXTIDS = "ContextIds", // Array
- PROP_EXECUTABLEPATHS = "ExecPaths", // Array
- PROP_LOCATION = "Location", // String
- PROP_SIZE = "Size", // Number
- PROP_ACCESSMODE = "AccessMode", // Number
- PROP_FILE = "File", // String
- PROP_LINE = "Line", // Number
- PROP_COLUMN = "Column", // Number
- PROP_PATTERN = "MaskValue", // Number
- PROP_MASK = "Mask", // Number
- PROP_STOP_GROUP = "StopGroup", // Array
- PROP_IGNORECOUNT = "IgnoreCount", // Number
- PROP_TIME = "Time", // Number
- PROP_SCALE = "TimeScale", // String
- PROP_UNITS = "TimeUnits", // String
- PROP_CONDITION = "Condition", // String
- PROP_TEMPORARY = "Temporary"; // Boolean
-
- /**
- * BreakpointType values
- */
- static final String
- TYPE_RELATIVE = "Software",
- TYPE_ABSOLUTE = "Hardware",
- TYPE_AUTO = "Auto";
-
- /**
- * AccessMode values
- */
- static final int
- ACCESSMODE_READ = 0x01,
- ACCESSMODE_WRITE = 0x02,
- ACCESSMODE_EXECUTE = 0x04,
- ACCESSMODE_CHANGE = 0x08;
-
- /**
- * TimeScale values
- */
- static final String
- TIMESCALE_RELATIVE = "Relative",
- TIMESCALE_ABSOLUTE = "Absolute";
-
- /**
- * TimeUnits values
- */
- static final String
- TIMEUNIT_NSECS = "Nanoseconds",
- TIMEUNIT_CYCLE_COUNT = "CycleCount",
- TIMEUNIT_INSTRUCTION_COUNT = "InstructionCount";
-
- /**
- * Breakpoint status field names.
- */
- static final String
- STATUS_INSTANCES = "Instances", // Array of Map<String,Object>
- STATUS_ERROR = "Error", // String
- STATUS_FILE = "File", // String
- STATUS_LINE = "Line", // Number
- STATUS_COLUMN = "Column"; // Number
-
- /**
- * Breakpoint instance field names.
- */
- static final String
- INSTANCE_ERROR = "Error", // String
- INSTANCE_CONTEXT = "LocationContext", // String
- INSTANCE_ADDRESS = "Address"; // Number
-
- /**
- * Breakpoint service capabilities.
- */
- static final String
- CAPABILITY_CONTEXT_ID = "ID", // String
- CAPABILITY_HAS_CHILDREN = "HasChildren", // Boolean
- CAPABILITY_ADDRESS = "Location", // Boolean
- CAPABILITY_CONDITION = "Condition", // Boolean
- CAPABILITY_FILE_LINE = "FileLine"; // Boolean
-
- /**
- * Call back interface for breakpoint service commands.
- */
- interface DoneCommand {
- /**
- * Called when command is done.
- * @param token - command handle.
- * @param error - error object or null.
- */
- void doneCommand(IToken token, Exception error);
- }
-
- /**
- * Download breakpoints data to target agent.
- * The command is intended to be used only to initialize target breakpoints table
- * when communication channel is open. After that, host should
- * notify target about (incremental) changes in breakpoint data by sending
- * add, change and remove commands.
- *
- * @param properties - array of breakpoints.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken set(Map<String,Object>[] properties, DoneCommand done);
-
- /**
- * Called when breakpoint is added into breakpoints table.
- * @param properties - breakpoint properties.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken add(Map<String,Object> properties, DoneCommand done);
-
- /**
- * Called when breakpoint properties are changed.
- * @param properties - breakpoint properties.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken change(Map<String,Object> properties, DoneCommand done);
-
- /**
- * Tell target to change (only) PROP_ENABLED breakpoint property to 'true'.
- * @param ids - array of enabled breakpoint identifiers.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken enable(String[] ids, DoneCommand done);
-
- /**
- * Tell target to change (only) PROP_ENABLED breakpoint property to 'false'.
- * @param ids - array of disabled breakpoint identifiers.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken disable(String[] ids, DoneCommand done);
-
- /**
- * Tell target to remove breakpoints.
- * @param id - unique breakpoint identifier.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken remove(String[] ids, DoneCommand done);
-
- /**
- * Upload IDs of breakpoints known to target agent.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken getIDs(DoneGetIDs done);
-
- /**
- * Call back interface for 'getIDs' command.
- */
- interface DoneGetIDs {
- /**
- * Called when 'getIDs' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- * @param ids - IDs of breakpoints known to target agent.
- */
- void doneGetIDs(IToken token, Exception error, String[] ids);
- }
-
- /**
- * Upload properties of given breakpoint from target agent breakpoint table.
- * @param id - unique breakpoint identifier.
- * @param done - command result call back object.
- */
- IToken getProperties(String id, DoneGetProperties done);
-
- /**
- * Call back interface for 'getProperties' command.
- */
- interface DoneGetProperties {
- /**
- * Called when 'getProperties' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- * @param properties - properties of the breakpoint.
- */
- void doneGetProperties(IToken token, Exception error, Map<String,Object> properties);
- }
-
- /**
- * Upload status of given breakpoint from target agent.
- * @param id - unique breakpoint identifier.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken getStatus(String id, DoneGetStatus done);
-
- /**
- * Call back interface for 'getStatus' command.
- */
- interface DoneGetStatus {
- /**
- * Called when 'getStatus' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- * @param status - status of the breakpoint.
- */
- void doneGetStatus(IToken token, Exception error, Map<String,Object> status);
- }
-
- /**
- * Report breakpoint service capabilities to clients so they
- * can adjust to different implementations of the service.
- * When called with a null ("") context ID the global capabilities are returned,
- * otherwise context specific capabilities are returned. A special capability
- * property is used to indicate that all child contexts have the same
- * capabilities.
- * @param id - a context ID or null.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken getCapabilities(String id, DoneGetCapabilities done);
-
- /**
- * Call back interface for 'getCapabilities' command.
- */
- interface DoneGetCapabilities {
- /**
- * Called when 'getCapabilities' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- * @param capabilities - breakpoints service capabilities description.
- */
- void doneGetCapabilities(IToken token, Exception error, Map<String,Object> capabilities);
- }
-
- /**
- * Breakpoints service events listener.
- * Note that contextAdded, contextChanged and contextRemoved events carry exactly same set
- * of breakpoint properties that was sent by a client to a target. The purpose of these events is to
- * let all clients know about breakpoints that were created by other clients.
- */
- interface BreakpointsListener {
-
- /**
- * Called when breakpoint status changes.
- * @param id - unique breakpoint identifier.
- * @param status - breakpoint status.
- */
- void breakpointStatusChanged(String id, Map<String,Object> status);
-
- /**
- * Called when a new breakpoints are added.
- * @param bps - array of breakpoints.
- */
- void contextAdded(Map<String,Object>[] bps);
-
- /**
- * Called when breakpoint properties change.
- * @param bps - array of breakpoints.
- */
- void contextChanged(Map<String,Object>[] bps);
-
- /**
- * Called when breakpoints are removed .
- * @param ids - array of breakpoint IDs.
- */
- void contextRemoved(String[] ids);
- }
-
- /**
- * Add breakpoints service event listener.
- * @param listener - object that implements BreakpointsListener interface.
- */
- void addListener(BreakpointsListener listener);
-
- /**
- * Remove breakpoints service event listener.
- * @param listener - object that implements BreakpointsListener interface.
- */
- void removeListener(BreakpointsListener listener);
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IDiagnostics.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IDiagnostics.java
deleted file mode 100644
index 52694f303..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IDiagnostics.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.services;
-
-import java.math.BigDecimal;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-/**
- * This is optional service that can be implemented by a peer.
- * If implemented, the service can be used for testing of the peer and
- * communication channel functionality and reliability.
- */
-
-public interface IDiagnostics extends IService {
-
- static final String NAME = "Diagnostics";
-
- /**
- * 'echo' command result returns same string that was given as command argument.
- * The command is used to test communication channel ability to transmit arbitrary strings in
- * both directions.
- * @param s - any string.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken echo(String s, DoneEcho done);
-
- /**
- * Call back interface for 'echo' command.
- */
- interface DoneEcho {
- /**
- * Called when 'echo' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- * @param s - same string as the command argument.
- */
- void doneEcho(IToken token, Throwable error, String s);
- }
-
- /**
- * 'echoFP' command result returns same floating point number that was given as command argument.
- * The command is used to test communication channel ability to transmit arbitrary floating point numbers in
- * both directions.
- * @param n - any floating point number.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken echoFP(BigDecimal n, DoneEchoFP done);
-
- /**
- * Call back interface for 'echoFP' command.
- */
- interface DoneEchoFP {
- /**
- * Called when 'echoFP' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- * @param n - same number as the command argument.
- */
- void doneEchoFP(IToken token, Throwable error, BigDecimal n);
- }
-
- /**
- * Get list of test names that are implemented by the service.
- * Clients can request remote peer to run a test from the list.
- * When started, a test performs a predefined set actions.
- * Nature of test actions is uniquely identified by test name.
- * Exact description of test actions is a contract between client and remote peer,
- * and it is not part of Diagnostics service specifications.
- * Clients should not attempt to run a test if they don't recognize the test name.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken getTestList(DoneGetTestList done);
-
- /**
- * Call back interface for 'getTestList' command.
- */
- interface DoneGetTestList {
- /**
- * Called when 'getTestList' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- * @param list - names of tests that are supported by the peer.
- */
- void doneGetTestList(IToken token, Throwable error, String[] list);
- }
-
- /**
- * Run a test. When started, a test performs a predefined set actions.
- * Nature of test actions is uniquely identified by test name.
- * Running test usually has associated execution context ID.
- * Depending on the test, the ID can be used with services RunControl and/or Processes services to control
- * test execution, and to obtain test results.
- * @param name - test name
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken runTest(String name, DoneRunTest done);
-
- /**
- * Call back interface for 'runTest' command.
- */
- interface DoneRunTest {
- /**
- * Called when 'runTest' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- * @param context_id - test execution contest ID.
- */
- void doneRunTest(IToken token, Throwable error, String context_id);
- }
-
- /**
- * Cancel execution of a test.
- * @param context_id - text execution context ID.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken cancelTest(String context_id, DoneCancelTest done);
-
- /**
- * Call back interface for 'cancelTest' command.
- */
- interface DoneCancelTest {
- /**
- * Called when 'cancelTest' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- */
- void doneCancelTest(IToken token, Throwable error);
- }
-
- /**
- * Get information about a symbol in text execution context.
- * @param context_id
- * @param symbol_name
- * @param done
- * @return
- */
- IToken getSymbol(String context_id, String symbol_name, DoneGetSymbol done);
-
- /**
- * Call back interface for 'getSymbol' command.
- */
- interface DoneGetSymbol {
- /**
- * Called when 'getSymbol' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- * @param symbol
- */
- void doneGetSymbol(IToken token, Throwable error, ISymbol symbol);
- }
-
- /**
- * Interface to access result value of 'getSymbol' command.
- */
- interface ISymbol {
- String getSectionName();
- Number getValue();
- boolean isUndef();
- boolean isCommon();
- boolean isGlobal();
- boolean isLocal();
- boolean isAbs();
- }
-
- /**
- * Create a pair of virtual streams, @see IStreams service.
- * Remote ends of the streams are connected, so any data sent into 'inp' stream
- * will become for available for reading from 'out' stream.
- * The command is used for testing virtual streams.
- * @param inp_buf_size - buffer size in bytes of the input stream.
- * @param out_buf_size - buffer size in bytes of the output stream.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken createTestStreams(int inp_buf_size, int out_buf_size, DoneCreateTestStreams done);
-
- /**
- * Call back interface for 'createTestStreams' command.
- */
- interface DoneCreateTestStreams {
-
- /**
- * Called when 'createTestStreams' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- * @param inp_id - the input stream ID.
- * @param out_id - the output stream ID.
- */
- void doneCreateTestStreams(IToken token, Throwable error, String inp_id, String out_id);
- }
-
- /**
- * Dispose a virtual stream that was created by 'createTestStreams' command.
- * @param id - the stream ID.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken disposeTestStream(String id, DoneDisposeTestStream done);
-
- /**
- * Call back interface for 'disposeTestStream' command.
- */
- interface DoneDisposeTestStream {
-
- /**
- * Called when 'createTestStreams' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- */
- void doneDisposeTestStream(IToken token, Throwable error);
- }
-
- /**
- * Send a command that is not implemented by peer.
- * Used to test handling of 'N' messages by communication channel.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken not_implemented_command(DoneNotImplementedCommand done);
-
- interface DoneNotImplementedCommand {
-
- /**
- * Called when 'not_implemented_command' command is done.
- * @param token - command handle.
- * @param error - error object.
- */
- void doneNotImplementedCommand(IToken token, Throwable error);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IExpressions.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IExpressions.java
deleted file mode 100644
index 0018fb837..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IExpressions.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.tm.tcf.services;
-
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-/**
- * Expressions service allows TCF client to perform expression evaluation on remote target.
- * The service can be used to retrieve or modify values of variables or any data structures in remote target memory.
- */
-public interface IExpressions extends IService {
-
- /**
- * Service name.
- */
- static final String NAME = "Expressions";
-
- /**
- * Expression object represent an expression that can be evaluated by remote target.
- * It has a unique ID and contains all information necessary to compute a value.
- * The object data usually includes:
- * 1. process, thread or stack frame ID that should be used to resolve symbol names;
- * 2. a script that can compute a value, like "x.y + z"
- */
- interface Expression {
- /**
- * Get context ID.
- * @return context ID.
- */
- String getID();
-
- /**
- * Get parent context ID.
- * @return parent context ID.
- */
- String getParentID();
-
- /**
- * Get expression script language ID.
- * @return language ID.
- */
- String getLanguage();
-
- /**
- * Return expression string - the script part of the context.
- * @return expression script string
- */
- String getExpression();
-
- /**
- * Get size of expression value in bits.
- * Can be 0 if value size is even number of bytes, use getSize() in such case.
- * @return size in bits.
- */
- int getBits();
-
- /**
- * Get size in bytes. The size can include extra (unused) bits.
- * This is "static" or "declared" size - as determined by expression type.
- * @return size in bytes.
- */
- int getSize();
-
- /**
- * Get expression type ID. Symbols service can be used to get type properties.
- * This is "static" or "declared" type ID, actual type of a value can be different -
- * if expression language supports dynamic typing.
- * @return type ID.
- */
- String getTypeID();
-
- /**
- * Check if the expression can be assigned a new value.
- * @return true if can assign.
- */
- boolean canAssign();
-
- /**
- * Get complete map of context properties.
- * @return map of context properties.
- */
- Map<String,Object> getProperties();
- }
-
- /**
- * Expression context property names.
- */
- static final String
- PROP_ID = "ID",
- PROP_PARENT_ID = "ParentID",
- PROP_LANGUAGE = "Language",
- PROP_EXPRESSION = "Expression",
- PROP_BITS = "Bits",
- PROP_SIZE = "Size",
- PROP_TYPE = "Type",
- PROP_CAN_ASSIGN = "CanAssign";
-
- /**
- * Value represents result of expression evaluation.
- * Note that same expression can be evaluated multiple times with different results.
- */
- interface Value {
-
- /**
- * Get value type class.
- * @see ISymbols.TypeClass
- * @return
- */
- ISymbols.TypeClass getTypeClass();
-
- /**
- * Get value type ID. Symbols service can be used to get type properties.
- * @return type ID.
- */
- String getTypeID();
-
- /**
- * Get execution context ID (thread or process) that owns type symbol for this value.
- * @return execution context ID.
- */
- String getExeContextID();
-
- /**
- * Check endianess of the values.
- * Big endian means decreasing numeric significance with increasing byte number.
- * @return true if big endian.
- */
- boolean isBigEndian();
-
- /**
- * Get value as array of bytes.
- * @return value as array of bytes.
- */
- byte[] getValue();
-
- /**
- * Get complete map of value properties.
- * @return map of value properties.
- */
- Map<String,Object> getProperties();
- }
-
- /**
- * Expression value property names.
- */
- static final String
- VAL_CLASS = "Class",
- VAL_TYPE = "Type",
- VAL_EXE_ID = "ExeID",
- VAL_BIG_ENDIAN = "BigEndian";
-
- /**
- * Retrieve expression context info for given context ID.
- * @see Expression
- *
- * @param id – context ID.
- * @param done - call back interface called when operation is completed.
- * @return - pending command handle.
- */
- IToken getContext(String id, DoneGetContext done);
-
- /**
- * Client call back interface for getContext().
- */
- interface DoneGetContext {
- /**
- * Called when context data retrieval is done.
- * @param token - command handle
- * @param error – error description if operation failed, null if succeeded.
- * @param context – context properties.
- */
- void doneGetContext(IToken token, Exception error, Expression context);
- }
-
- /**
- * Retrieve children IDs for given parent ID.
- * Meaning of the operation depends on parent kind:
- * 1. expression with type of a struct, union, or class - fields;
- * 2. expression with type of an enumeration - enumerators;
- * 3. expression with type of an array - array elements;
- * 4. stack frame - function arguments and local variables;
- * 5. thread - top stack frame function arguments and local variables;
- * 6. process - global variables;
- *
- * Children list does *not* include IDs of expressions that were created by clients
- * using "create" command.
- *
- * @param parent_context_id – parent context ID.
- * @param done - call back interface called when operation is completed.
- * @return - pending command handle.
- */
- IToken getChildren(String parent_context_id, DoneGetChildren done);
-
- /**
- * Client call back interface for getChildren().
- */
- interface DoneGetChildren {
- /**
- * Called when context list retrieval is done.
- * @param token - command handle
- * @param error – error description if operation failed, null if succeeded.
- * @param context_ids – array of available context IDs.
- */
- void doneGetChildren(IToken token, Exception error, String[] context_ids);
- }
-
- /**
- * Create an expression context.
- * The context should be disposed after use.
- * @param parent_id - a context ID that can be used to resolve symbol names.
- * @param language - language of expression script, null means default language
- * @param expression - expression script
- * @param done - call back interface called when operation is completed.
- * @return - pending command handle.
- */
- IToken create(String parent_id, String language, String expression, DoneCreate done);
-
- /**
- * Client call back interface for create().
- */
- interface DoneCreate {
- /**
- * Called when context create context command is done.
- * @param token - command handle
- * @param error – error description if operation failed, null if succeeded.
- * @param context – context properties.
- */
- void doneCreate(IToken token, Exception error, Expression context);
- }
-
- /**
- * Dispose an expression context that was created by create()
- * @param id - the expression context ID
- * @param done - call back interface called when operation is completed.
- * @return - pending command handle.
- */
- IToken dispose(String id, DoneDispose done);
-
- /**
- * Client call back interface for dispose().
- */
- interface DoneDispose {
- /**
- * Called when context dispose command is done.
- * @param token - command handle
- * @param error – error description if operation failed, null if succeeded.
- */
- void doneDispose(IToken token, Exception error);
- }
-
- /**
- * Evaluate value of an expression context.
- * @param id - the expression context ID
- * @param done - call back interface called when operation is completed.
- * @return - pending command handle.
- */
- IToken evaluate(String id, DoneEvaluate done);
-
- /**
- * Client call back interface for evaluate().
- */
- interface DoneEvaluate {
- /**
- * Called when context dispose command is done.
- * @param token - command handle
- * @param error – error description if operation failed, null if succeeded.
- * @param value - expression evaluation result
- */
- void doneEvaluate(IToken token, Exception error, Value value);
- }
-
- /**
- * Assign a value to memory location determined by an expression.
- * @param id - expression ID.
- * @param value - value as an array of bytes.
- * @param done - call back interface called when operation is completed.
- * @return - pending command handle.
- */
- IToken assign(String id, byte[] value, DoneAssign done);
-
- /**
- * Client call back interface for assign().
- */
- interface DoneAssign {
- /**
- * Called when assign command is done.
- * @param token - command handle
- * @param error – error description if operation failed, null if succeeded.
- */
- void doneAssign(IToken token, Exception error);
- }
-
- /**
- * Add expressions service event listener.
- * @param listener - event listener implementation.
- */
- void addListener(ExpressionsListener listener);
-
- /**
- * Remove expressions service event listener.
- * @param listener - event listener implementation.
- */
- void removeListener(ExpressionsListener listener);
-
- /**
- * Registers event listener is notified when registers context hierarchy
- * changes, and when a register is modified by the service commands.
- */
- interface ExpressionsListener {
-
- /**
- * Called when expression value was changed and clients
- * need to update themselves. Clients, at least, should invalidate
- * corresponding cached expression data.
- * Not every change is notified - it is not possible,
- * only those, which are not caused by normal execution of the debuggee.
- * At least, changes caused by "assign" command should be notified.
- * @param id - expression context ID.
- */
- void valueChanged(String id);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IFileSystem.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IFileSystem.java
deleted file mode 100644
index 0c4e62ed4..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IFileSystem.java
+++ /dev/null
@@ -1,664 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.services;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-
-/**
- * File System service provides file transfer (and more generally file
- * system access) functionality in TCF. The service design is
- * derived from SSH File Transfer Protocol specifications.
- *
- * Request Synchronization and Reordering
- *
- * The protocol and implementations MUST process requests relating to
- * the same file in the order in which they are received. In other
- * words, if an application submits multiple requests to the server, the
- * results in the responses will be the same as if it had sent the
- * requests one at a time and waited for the response in each case. For
- * example, the server may process non-overlapping read/write requests
- * to the same file in parallel, but overlapping reads and writes cannot
- * be reordered or parallelized. However, there are no ordering
- * restrictions on the server for processing requests from two different
- * file transfer connections. The server may interleave and parallelize
- * them at will.
- *
- * There are no restrictions on the order in which responses to
- * outstanding requests are delivered to the client, except that the
- * server must ensure fairness in the sense that processing of no
- * request will be indefinitely delayed even if the client is sending
- * other requests so that there are multiple outstanding requests all
- * the time.
- *
- * There is no limit on the number of outstanding (non-acknowledged)
- * requests that the client may send to the server. In practice this is
- * limited by the buffering available on the data stream and the queuing
- * performed by the server. If the server's queues are full, it should
- * not read any more data from the stream, and flow control will prevent
- * the client from sending more requests.
- *
- * File Names
- *
- * This protocol represents file names as strings. File names are
- * assumed to use the slash ('/') character as a directory separator.
- *
- * File names starting with a slash are "absolute", and are relative to
- * the root of the file system. Names starting with any other character
- * are relative to the user's default directory (home directory). Client
- * can use 'user()' command to retrieve current user home directory.
- *
- * Servers SHOULD interpret a path name component ".." as referring to
- * the parent directory, and "." as referring to the current directory.
- * If the server implementation limits access to certain parts of the
- * file system, it must be extra careful in parsing file names when
- * enforcing such restrictions. There have been numerous reported
- * security bugs where a ".." in a path name has allowed access outside
- * the intended area.
- *
- * An empty path name is valid, and it refers to the user's default
- * directory (usually the user's home directory).
- *
- * Otherwise, no syntax is defined for file names by this specification.
- * Clients should not make any other assumptions; however, they can
- * splice path name components returned by readdir() together
- * using a slash ('/') as the separator, and that will work as expected.
- */
-public interface IFileSystem extends IService {
-
- /**
- * Service name.
- */
- static final String NAME = "FileSystem";
-
- /**
- * Flags to be used with open() method.
- */
- static final int
-
- /**
- * Open the file for reading.
- */
- TCF_O_READ = 0x00000001,
-
- /**
- * Open the file for writing. If both this and TCF_O_READ are
- * specified, the file is opened for both reading and writing.
- */
- TCF_O_WRITE = 0x00000002,
-
- /**
- * Force all writes to append data at the end of the file.
- */
- TCF_O_APPEND = 0x00000004,
-
- /**
- * If this flag is specified, then a new file will be created if one
- * does not already exist (if TCF_O_TRUNC is specified, the new file will
- * be truncated to zero length if it previously exists).
- */
- TCF_O_CREAT = 0x00000008,
-
- /**
- * Forces an existing file with the same name to be truncated to zero
- * length when creating a file by specifying TCF_O_CREAT.
- * TCF_O_CREAT MUST also be specified if this flag is used.
- */
- TCF_O_TRUNC = 0x00000010,
-
- /**
- * Causes the request to fail if the named file already exists.
- * TCF_O_CREAT MUST also be specified if this flag is used.
- */
- TCF_O_EXCL = 0x00000020;
-
- /**
- * Flags to be used together with FileAttrs.
- * The flags specify which of the fields are present. Those fields
- * for which the corresponding flag is not set are not present (not
- * included in the message).
- */
- static final int
- ATTR_SIZE = 0x00000001,
- ATTR_UIDGID = 0x00000002,
- ATTR_PERMISSIONS = 0x00000004,
- ATTR_ACMODTIME = 0x00000008;
-
- /**
- * FileAttrs is used both when returning file attributes from
- * the server and when sending file attributes to the server. When
- * sending it to the server, the flags field specifies which attributes
- * are included, and the server will use default values for the
- * remaining attributes (or will not modify the values of remaining
- * attributes). When receiving attributes from the server, the flags
- * specify which attributes are included in the returned data. The
- * server normally returns all attributes it knows about.
- */
- final static class FileAttrs {
-
- /**
- * The `flags' specify which of the fields are present.
- */
- public final int flags;
-
- /**
- * The `size' field specifies the size of the file in bytes.
- */
- public final long size;
-
- /**
- * The `uid' and `gid' fields contain numeric Unix-like user and group
- * identifiers, respectively.
- */
- public final int uid;
- public final int gid;
-
- /**
- * The `permissions' field contains a bit mask of file permissions as
- * defined by posix [1].
- */
- public final int permissions;
-
- /**
- * The `atime' and `mtime' contain the access and modification times of
- * the files, respectively. They are represented as milliseconds from
- * midnight Jan 1, 1970 in UTC.
- */
- public final long atime;
- public final long mtime;
-
- /**
- * Additional (non-standard) attributes.
- */
- public final Map<String,Object> attributes;
-
- public FileAttrs(int flags, long size, int uid, int gid,
- int permissions, long atime, long mtime, Map<String,Object> attributes) {
- this.flags = flags;
- this.size = size;
- this.uid = uid;
- this.gid = gid;
- this.permissions = permissions;
- this.atime = atime;
- this.mtime = mtime;
- this.attributes = attributes;
- }
-
- /**
- * Determines if the file system object is a file on the remote file system.
- *
- * @return true if and only if the object on the remote system can be considered to have "contents" that
- * have the potential to be read and written as a byte stream.
- */
- public boolean isFile() {
- if ((flags & ATTR_PERMISSIONS) == 0) return false;
- return (permissions & S_IFMT) == S_IFREG;
- }
-
- /**
- * Determines if the file system object is a directory on the remote file system.
- *
- * @return true if and only if the object on the remote system is a directory.
- * That is, it contains entries that can be interpreted as other files.
- */
- public boolean isDirectory() {
- if ((flags & ATTR_PERMISSIONS) == 0) return false;
- return (permissions & S_IFMT) == S_IFDIR;
- }
- }
-
- /**
- * The following flags are defined for the 'permissions' field:
- */
- static final int
- S_IFMT = 0170000, // bitmask for the file type bitfields
- S_IFSOCK = 0140000, // socket
- S_IFLNK = 0120000, // symbolic link
- S_IFREG = 0100000, // regular file
- S_IFBLK = 0060000, // block device
- S_IFDIR = 0040000, // directory
- S_IFCHR = 0020000, // character device
- S_IFIFO = 0010000, // fifo
- S_ISUID = 0004000, // set UID bit
- S_ISGID = 0002000, // set GID bit (see below)
- S_ISVTX = 0001000, // sticky bit (see below)
- S_IRWXU = 00700, // mask for file owner permissions
- S_IRUSR = 00400, // owner has read permission
- S_IWUSR = 00200, // owner has write permission
- S_IXUSR = 00100, // owner has execute permission
- S_IRWXG = 00070, // mask for group permissions
- S_IRGRP = 00040, // group has read permission
- S_IWGRP = 00020, // group has write permission
- S_IXGRP = 00010, // group has execute permission
- S_IRWXO = 00007, // mask for permissions for others (not in group)
- S_IROTH = 00004, // others have read permission
- S_IWOTH = 00002, // others have write permisson
- S_IXOTH = 00001; // others have execute permission
-
- final static class DirEntry {
- /**
- * `filename' is a file name being returned. It is a relative name within
- * the directory, without any path components;
- */
- public final String filename;
-
- /**
- * `longname' is an expanded format for the file name, similar to what
- * is returned by "ls -l" on Unix systems.
- * The format of the `longname' field is unspecified by this protocol.
- * It MUST be suitable for use in the output of a directory listing
- * command (in fact, the recommended operation for a directory listing
- * command is to simply display this data). However, clients SHOULD NOT
- * attempt to parse the longname field for file attributes; they SHOULD
- * use the attrs field instead.
- */
- public final String longname;
-
- /**
- * `attrs' is the attributes of the file.
- */
- public final FileAttrs attrs;
-
- public DirEntry(String filename, String longname, FileAttrs attrs) {
- this.filename = filename;
- this.longname = longname;
- this.attrs = attrs;
- }
- }
-
- /**
- * Opaque representation of open file handle.
- * Note: open file handle can be used only with service instance that
- * created the handle.
- */
- interface IFileHandle {
- IFileSystem getService();
- }
-
- /**
- * Service specific error codes.
- */
- static final int
-
- /**
- * Indicates end-of-file condition; for read() it means that no
- * more data is available in the file, and for readdir() it
- * indicates that no more files are contained in the directory.
- */
- STATUS_EOF = 0x10001,
-
- /**
- * This code is returned when a reference is made to a file which
- * should exist but doesn't.
- */
- STATUS_NO_SUCH_FILE = 0x10002,
-
- /**
- * is returned when the authenticated user does not have sufficient
- * permissions to perform the operation.
- */
- STATUS_PERMISSION_DENIED = 0x10003;
-
- /**
- * The class to represent File System error reports.
- */
- @SuppressWarnings("serial")
- abstract static class FileSystemException extends IOException {
-
- protected FileSystemException(String message) {
- super(message);
- }
-
- protected FileSystemException(Exception x) {
- super(x.getMessage());
- initCause(x);
- }
-
- /**
- * Get error code. The code can be standard TCF error code or
- * one of service specific codes, see STATUS_*.
- * @return error code.
- */
- public abstract int getStatus();
- }
-
- /**
- * Open or create a file on a remote system.
- *
- * @param file_name specifies the file name. See 'File Names' for more information.
- * @param flags is a bit mask of TCF_O_* flags.
- * @param attrs specifies the initial attributes for the file.
- * Default values will be used for those attributes that are not specified.
- * @param done is call back object.
- * @return pending command handle.
- */
- IToken open(String file_name, int flags, FileAttrs attrs, DoneOpen done);
-
- interface DoneOpen {
- void doneOpen(IToken token, FileSystemException error, IFileHandle handle);
- }
-
- /**
- * Close a file on a remote system.
- *
- * @param handle is a handle previously returned in the response to
- * open() or opendir().
- * @param done is call back object.
- * @return pending command handle.
- */
- IToken close(IFileHandle handle, DoneClose done);
-
- interface DoneClose {
- void doneClose(IToken token, FileSystemException error);
- }
-
- /**
- * Read bytes from an open file.
- * In response to this request, the server will read as many bytes as it
- * can from the file (up to `len'), and return them in a byte array.
- * If an error occurs or EOF is encountered, the server may return
- * fewer bytes then requested. Call back method doneRead() argument 'error'
- * will be not null in case of error, and argument 'eof' will be
- * true in case of EOF. For normal disk files, it is guaranteed
- * that this will read the specified number of bytes, or up to end of file
- * or error. For e.g. device files this may return fewer bytes than requested.
- *
- * @param handle is an open file handle returned by open().
- * @param offset is the offset (in bytes) relative
- * to the beginning of the file from where to start reading.
- * @param len is the maximum number of bytes to read.
- * @param done is call back object.
- * @return pending command handle.
- */
- IToken read(IFileHandle handle, long offset, int len, DoneRead done);
-
- interface DoneRead {
- void doneRead(IToken token, FileSystemException error, byte[] data, boolean eof);
- }
-
- /**
- * Write bytes into an open file.
- * The write will extend the file if writing beyond the end of the file.
- * It is legal to write way beyond the end of the file; the semantics
- * are to write zeroes from the end of the file to the specified offset
- * and then the data.
- *
- * @param handle is an open file handle returned by open().
- * @param offset is the offset (in bytes) relative
- * to the beginning of the file from where to start writing.
- * @param data is byte array that contains data for writing.
- * @param data_pos if offset in 'data' of first byte to write.
- * @param data_size is the number of bytes to write.
- * @param done is call back object.
- * @return pending command handle.
- */
- IToken write(IFileHandle handle, long offset,
- byte[] data, int data_pos, int data_size, DoneWrite done);
-
- interface DoneWrite {
- void doneWrite(IToken token, FileSystemException error);
- }
-
- /**
- * Retrieve file attributes.
- *
- * @param path - specifies the file system object for which
- * status is to be returned.
- * @param done is call back object.
- * @return pending command handle.
- */
- IToken stat(String path, DoneStat done);
-
- /**
- * Retrieve file attributes.
- * Unlike 'stat()', 'lstat()' does not follow symbolic links.
- *
- * @param path - specifies the file system object for which
- * status is to be returned.
- * @param done is call back object.
- * @return pending command handle.
- */
- IToken lstat(String path, DoneStat done);
-
- /**
- * Retrieve file attributes for an open file (identified by the file handle).
- *
- * @param handle is a file handle returned by 'open()'.
- * @param done is call back object.
- * @return pending command handle.
- */
- IToken fstat(IFileHandle handle, DoneStat done);
-
- interface DoneStat {
- void doneStat(IToken token, FileSystemException error, FileAttrs attrs);
- }
-
- /**
- * Set file attributes.
- * This request is used for operations such as changing the ownership,
- * permissions or access times, as well as for truncating a file.
- * An error will be returned if the specified file system object does
- * not exist or the user does not have sufficient rights to modify the
- * specified attributes.
- *
- * @param path specifies the file system object (e.g. file or directory)
- * whose attributes are to be modified.
- * @param attrs specifies the modifications to be made to file attributes.
- * @param done is call back object.
- * @return pending command handle.
- */
- IToken setstat(String path, FileAttrs attrs, DoneSetStat done);
-
- /**
- * Set file attributes for an open file (identified by the file handle).
- * This request is used for operations such as changing the ownership,
- * permissions or access times, as well as for truncating a file.
- *
- * @param handle is a file handle returned by 'open()'.
- * @param attrs specifies the modifications to be made to file attributes.
- * @param done is call back object.
- * @return pending command handle.
- */
- IToken fsetstat(IFileHandle handle, FileAttrs attrs, DoneSetStat done);
-
- interface DoneSetStat {
- void doneSetStat(IToken token, FileSystemException error);
- }
-
- /**
- * The opendir() command opens a directory for reading.
- * Once the directory has been successfully opened, files (and
- * directories) contained in it can be listed using readdir() requests.
- * When the client no longer wishes to read more names from the
- * directory, it SHOULD call close() for the handle. The handle
- * should be closed regardless of whether an error has occurred or not.
-
- * @param path - name of the directory to be listed (without any trailing slash).
- * @param done - result call back object.
- * @return pending command handle.
- */
- IToken opendir(String path, DoneOpen done);
-
- /**
- * The files in a directory can be listed using the opendir() and
- * readdir() requests. Each readdir() request returns one
- * or more file names with full file attributes for each file. The
- * client should call readdir() repeatedly until it has found the
- * file it is looking for or until the server responds with a
- * message indicating an error or end of file. The client should then
- * close the handle using the close() request.
- * Note: directory entries "." and ".." are NOT included into readdir()
- * response.
- * @param handle - file handle created by opendir()
- * @param done - result call back object.
- * @return pending command handle.
- */
- IToken readdir(IFileHandle handle, DoneReadDir done);
-
- interface DoneReadDir {
- void doneReadDir(IToken token, FileSystemException error, DirEntry[] entries, boolean eof);
- }
-
- /**
- * Create a directory on the server.
- *
- * @param path - specifies the directory to be created.
- * @param attrs - new directory attributes.
- * @param done - result call back object.
- * @return pending command handle.
- */
- IToken mkdir(String path, FileAttrs attrs, DoneMkDir done);
-
- interface DoneMkDir {
- void doneMkDir(IToken token, FileSystemException error);
- }
-
- /**
- * Remove a directory.
- * An error will be returned if no directory
- * with the specified path exists, or if the specified directory is not
- * empty, or if the path specified a file system object other than a
- * directory.
- *
- * @param path - specifies the directory to be removed.
- * @param done - result call back object.
- * @return pending command handle.
- */
- IToken rmdir(String path, DoneRemove done);
-
- interface DoneRemove {
- void doneRemove(IToken token, FileSystemException error);
- }
-
- /**
- * Retrieve file system roots - top level file system objects.
- * UNIX file system can report just one root with path "/". Other types of systems
- * can have more the one root. For example, Windows server can return multiple roots:
- * one per disc (e.g. "/C:/", "/D:/", etc.). Note: even Windows implementation of
- * the service must use forward slash as directory separator, and must start
- * absolute path with "/". Server should implement proper translation of
- * protocol file names to OS native names and back.
- *
- * @param done - result call back object.
- * @return pending command handle.
- */
- IToken roots(DoneRoots done);
-
- interface DoneRoots {
- void doneRoots(IToken token, FileSystemException error, DirEntry[] entries);
- }
-
- /**
- * Remove a file or symbolic link.
- * This request cannot be used to remove directories.
- *
- * @param file_name is the name of the file to be removed.
- * @param done - result call back object.
- * @return pending command handle.
- */
- IToken remove(String file_name, DoneRemove done);
-
- /**
- * Canonicalize any given path name to an absolute path.
- * This is useful for converting path names containing ".." components or
- * relative pathnames without a leading slash into absolute paths.
- *
- * @param path specifies the path name to be canonicalized.
- * @param done - result call back object.
- * @return pending command handle.
- */
- IToken realpath(String path, DoneRealPath done);
-
- interface DoneRealPath {
- void doneRealPath(IToken token, FileSystemException error, String path);
- }
-
- /**
- * Rename a file.
- * It is an error if there already exists a file
- * with the name specified by 'new_path'. The server may also fail rename
- * requests in other situations, for example if `old_path' and `new_path'
- * point to different file systems on the server.
- *
- * @param old_path is the name of an existing file or directory.
- * @param new_path is the new name for the file or directory.
- * @param done - result call back object.
- * @return pending command handle.
- */
- IToken rename(String old_path, String new_path, DoneRename done);
-
- interface DoneRename {
- void doneRename(IToken token, FileSystemException error);
- }
-
- /**
- * Read the target of a symbolic link.
- *
- * @param path specifies the path name of the symbolic link to be read.
- * @param done - result call back object.
- * @return pending command handle.
- */
- IToken readlink(String path, DoneReadLink done);
-
- interface DoneReadLink {
- void doneReadLink(IToken token, FileSystemException error, String path);
- }
-
- /**
- * Create a symbolic link on the server.
- *
- * @param link_path specifies the path name of the symbolic link to be created.
- * @param target_path specifies the target of the symbolic link.
- * @param done - result call back object.
- * @return pending command handle.
- */
- IToken symlink(String link_path, String target_path, DoneSymLink done);
-
- interface DoneSymLink {
- void doneSymLink(IToken token, FileSystemException error);
- }
-
- /**
- * Copy a file on remote system.
- *
- * @param src_path specifies the path name of the file to be copied.
- * @param dst_path specifies destination file name.
- * @param copy_permissions - if true then copy source file permissions.
- * @param copy_ownership - if true then copy source file UID and GID.
- * @param done - result call back object.
- * @return pending command handle.
- */
- IToken copy(String src_path, String dst_path,
- boolean copy_permissions, boolean copy_ownership, DoneCopy done);
-
- interface DoneCopy {
- void doneCopy(IToken token, FileSystemException error);
- }
-
- /**
- * Retrieve information about user account, which is used by server
- * to access file system on behalf of the client.
- *
- * @param done - result call back object.
- * @return pending command handle.
- */
- IToken user(DoneUser done);
-
- interface DoneUser {
- void doneUser(IToken token, FileSystemException error,
- int real_uid, int effective_uid, int real_gid, int effective_gid,
- String home);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ILineNumbers.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ILineNumbers.java
deleted file mode 100644
index 4a4e11f81..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ILineNumbers.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.services;
-
-import java.math.BigInteger;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-/**
- * Line numbers service associates locations in the source files with the corresponding
- * machine instruction addresses in the executable object.
- */
-public interface ILineNumbers extends IService {
-
- static final String NAME = "LineNumbers";
-
- /**
- * TextArea represent a continues area in source text mapped to
- * continues range of code addresses.
- * Line and columns are counted starting from 1.
- * File name can be relative path, in such case client should
- * use TextArea directory name as origin for the path.
- * File and directory names are valid on a host where code was compiled.
- * It is client responsibility to map names to this host file system.
- */
- final class CodeArea {
- public final String directory;
- public final String file;
- public final int start_line;
- public final int start_column;
- public final int end_line;
- public final int end_column;
- public final Number start_address;
- public final Number end_address;
- public final int isa;
- public final boolean is_statement;
- public final boolean basic_block;
- public final boolean prologue_end;
- public final boolean epilogue_begin;
-
- public CodeArea(String directory, String file, int start_line, int start_column,
- int end_line, int end_column, Number start_address, Number end_address, int isa,
- boolean is_statement, boolean basic_block,
- boolean prologue_end, boolean epilogue_begin) {
- this.directory = directory;
- this.file = file;
- this.start_line = start_line;
- this.start_column = start_column;
- this.end_line = end_line;
- this.end_column = end_column;
- this.start_address = start_address;
- this.end_address = end_address;
- this.isa = isa;
- this.is_statement = is_statement;
- this.basic_block = basic_block;
- this.prologue_end = prologue_end;
- this.epilogue_begin = epilogue_begin;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof CodeArea)) return false;
- CodeArea a = (CodeArea)o;
- if (start_line != a.start_line) return false;
- if (start_column != a.start_column) return false;
- if (end_line != a.end_line) return false;
- if (end_column != a.end_column) return false;
- if (isa != a.isa) return false;
- if (is_statement != a.is_statement) return false;
- if (basic_block != a.basic_block) return false;
- if (prologue_end != a.prologue_end) return false;
- if (epilogue_begin != a.epilogue_begin) return false;
- if (start_address != null && !start_address.equals(a.start_address)) return false;
- if (start_address == null && a.start_address != null) return false;
- if (end_address != null && !end_address.equals(a.end_address)) return false;
- if (end_address == null && a.end_address != null) return false;
- if (file != null && !file.equals(a.file)) return false;
- if (file == null && a.file != null) return false;
- if (directory != null && !directory.equals(a.directory)) return false;
- if (directory == null && a.directory != null) return false;
- return true;
- }
-
- @Override
- public int hashCode() {
- int h = 0;
- if (file != null) h += file.hashCode();
- return h + start_line + start_column + end_line + end_column;
- }
-
- @Override
- public String toString() {
- StringBuffer bf = new StringBuffer();
- bf.append('[');
- if (directory != null) {
- bf.append(directory);
- bf.append(':');
- }
- if (file != null) {
- bf.append(file);
- bf.append(':');
- }
- bf.append(start_line);
- if (start_column != 0) {
- bf.append('.');
- bf.append(start_column);
- }
- bf.append("..");
- bf.append(end_line);
- if (end_column != 0) {
- bf.append('.');
- bf.append(end_column);
- }
- bf.append(" -> ");
- if (start_address != null) {
- bf.append("0x");
- bf.append(new BigInteger(start_address.toString()).toString(16));
- }
- else {
- bf.append('0');
- }
- bf.append("..");
- if (end_address != null) {
- bf.append("0x");
- bf.append(new BigInteger(end_address.toString()).toString(16));
- }
- else {
- bf.append('0');
- }
- if (isa != 0) {
- bf.append(",isa ");
- bf.append(isa);
- }
- if (is_statement) {
- bf.append(",statement");
- }
- if (basic_block) {
- bf.append(",basic block");
- }
- if (prologue_end) {
- bf.append(",prologue end");
- }
- if (epilogue_begin) {
- bf.append(",epilogue begin");
- }
- bf.append(']');
- return bf.toString();
- }
- }
-
- IToken mapToSource(String context_id, Number start_address, Number end_address, DoneMapToSource done);
-
- interface DoneMapToSource {
- void doneMapToSource(IToken token, Exception error, CodeArea[] areas);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ILocator.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ILocator.java
deleted file mode 100644
index f4aa002f7..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ILocator.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.services;
-
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IPeer;
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-
-/**
- * ILocator service uses transport layer to search for peers and to collect data about
- * peer’s attributes and capabilities (services). Discovery mechanism depends on transport protocol
- * and is part of that protocol handler. Targets, known to other hosts, can be found through
- * remote instances of ILocator service. Automatically discovered targets require no further
- * configuration. Additional targets can be configured manually.
- *
- * Clients should use Protocol.getLocator() to obtain local instance of ILocator,
- * then ILocator.getPeers() can be used to get list of available peers (hosts and targets).
- */
-
-public interface ILocator extends IService {
-
- static final String NAME = "Locator";
-
- /**
- * Peer data retention period in milliseconds.
- */
- static final long DATA_RETENTION_PERIOD = 60 * 1000;
-
- /**
- * Auto-configuration command and response codes.
- */
- static final int
- CONF_REQ_INFO = 1,
- CONF_PEER_INFO = 2,
- CONF_REQ_SLAVES = 3,
- CONF_SLAVES_INFO = 4;
-
- /**
- * @return Locator service name: "Locator"
- */
- String getName();
-
- /**
- * Get map (ID -> IPeer) of available peers (hosts and targets).
- * The method return cached (currently known to the framework) list of peers.
- * The list is updated according to event received from transport layer
- */
- Map<String,IPeer> getPeers();
-
- /**
- * Redirect this service channel to given peer using this service as a proxy.
- * @param peer_id - Peer ID.
- */
- IToken redirect(String peer_id, DoneRedirect done);
-
- interface DoneRedirect {
- void doneRedirect(IToken token, Exception error);
- }
-
- /**
- * Call back after TCF messages sent to this target up to this moment are delivered.
- * This method is intended for synchronization of messages
- * across multiple channels.
- *
- * Note: Cross channel synchronization can reduce performance and throughput.
- * Most clients don't need channel synchronization and should not call this method.
- *
- * @param done will be executed by dispatch thread after communication
- * messages are delivered to corresponding targets.
- *
- * This is internal API, TCF clients should use {@code org.eclipse.tm.tcf.protocol.Protocol}.
- */
- IToken sync(DoneSync done);
-
- interface DoneSync {
- void doneSync(IToken token);
- }
-
- /**
- * Add a listener for ILocator service events.
- */
- void addListener(LocatorListener listener);
-
- /**
- * Remove a listener for ILocator service events.
- */
- void removeListener(LocatorListener listener);
-
- interface LocatorListener {
- /**
- * A new peer is added into locator peer table.
- * @param peer
- */
- void peerAdded(IPeer peer);
-
- /**
- * Peer attributes have changed.
- * @param peer
- */
- void peerChanged(IPeer peer);
-
- /**
- * A peer is removed from locator peer table.
- * @param id - peer ID
- */
- void peerRemoved(String id);
-
- /**
- * Peer heart beat detected.
- * @param id - peer ID
- */
- void peerHeartBeat(String id);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IMemory.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IMemory.java
deleted file mode 100644
index a77941d5c..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IMemory.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.services;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-
-/**
- * IMemory service provides basic operations to read/write memory on a target.
- */
-public interface IMemory extends IService {
-
- static final String NAME = "Memory";
-
- /**
- * Context property names.
- */
- static final String
- PROP_ID = "ID", /** String, ID of the context, same as getContext command argument */
- PROP_PARENT_ID = "ParentID", /** String, ID of a parent context */
- PROP_PROCESS_ID = "ProcessID", /** String, process ID, see Processes service */
- PROP_BIG_ENDIAN = "BigEndian", /** Boolean, true if memory is big-endian */
- PROP_ADDRESS_SIZE = "AddressSize", /** Number, size of memory address in bytes */
- PROP_NAME = "Name", /** String, name of the context, can be used for UI purposes */
- PROP_START_BOUND = "StartBound", /** Number, lowest address (inclusive) which is valid for the context */
- PROP_END_BOUND = "EndBound", /** Number, highest address (inclusive) which is valid for the context */
- PROP_ACCESS_TYPES = "AccessTypes"; /** Array of String, the access types allowed for this context */
-
- /**
- * Values of "AccessTypes".
- * Target system can support multiple different memory access types, like instruction and data access.
- * Different access types can use different logic for address translation and memory mapping, so they can
- * end up accessing different data bits, even if address is the same.
- * Each distinct access type should be represented by separate memory context.
- * A memory context can represent multiple access types if they are equivalent - all access same memory bits.
- * Same data bits can be exposed through multiple memory contexts.
- */
- static final String
- ACCESS_INSTRUCTION = "instruction", /** Context represent instructions fetch access */
- ACCESS_DATA = "data", /** Context represents data access */
- ACCESS_IO = "io", /** Context represents IO peripherals */
- ACCESS_USER = "user", /** Context represents a user (e.g. application running in Linux) view to memory */
- ACCESS_SUPERVISOR = "supervisor", /** Context represents a supervisor (e.g. Linux kernel) view to memory */
- ACCESS_HYPERVISOR = "hypervisor", /** Context represents a hypervisor view to memory */
- ACCESS_VIRTUAL = "virtual", /** Context uses virtual addresses */
- ACCESS_PHYSICAL = "physical", /** Context uses physical addresses */
- ACCESS_CACHE = "cache", /** Context is a cache */
- ACCESS_TLB = "tlb"; /** Context is a TLB memory */
-
- /**
- * Retrieve context info for given context ID.
- *
- * @param id – context ID.
- * @param done - call back interface called when operation is completed.
- * @return - pending command handle.
- */
- IToken getContext(String id, DoneGetContext done);
-
- /**
- * Client call back interface for getContext().
- */
- interface DoneGetContext {
- /**
- * Called when context data retrieval is done.
- * @param error – error description if operation failed, null if succeeded.
- * @param context – context data.
- */
- void doneGetContext(IToken token, Exception error, MemoryContext context);
- }
-
- /**
- * Retrieve contexts available for memory commands.
- * A context corresponds to an execution thread, process, address space, etc.
- * A context can belong to a parent context. Contexts hierarchy can be simple
- * plain list or it can form a tree. It is up to target agent developers to choose
- * layout that is most descriptive for a given target. Context IDs are valid across
- * all services. In other words, all services access same hierarchy of contexts,
- * with same IDs, however, each service accesses its own subset of context's
- * attributes and functionality, which is relevant to that service.
- *
- * @param parent_context_id – parent context ID. Can be null –
- * to retrieve top level of the hierarchy, or one of context IDs retrieved
- * by previous getChildren commands.
- * @param done - call back interface called when operation is completed.
- * @return - pending command handle.
- */
- IToken getChildren(String parent_context_id, DoneGetChildren done);
-
- /**
- * Client call back interface for getChildren().
- */
- interface DoneGetChildren {
- /**
- * Called when context list retrieval is done.
- * @param error – error description if operation failed, null if succeeded.
- * @param context_ids – array of available context IDs.
- */
- void doneGetChildren(IToken token, Exception error, String[] context_ids);
- }
-
- /**
- * Memory access mode:
- * Carry on when some of the memory cannot be accessed and
- * return MemoryError at the end if any of the bytes
- * were not processed correctly.
- */
- final static int MODE_CONTINUEONERROR = 0x1;
-
- /**
- * Memory access mode:
- * Verify result of memory operations (by reading and comparing).
- */
- final static int MODE_VERIFY = 0x2;
-
- interface MemoryContext {
-
- /**
- * Get context ID.
- * @return context ID.
- */
- String getID();
-
- /**
- * Get parent context ID.
- * @return parent ID.
- */
- String getParentID();
-
- /**
- * Get process ID, if applicable.
- * @return process ID.
- */
- String getProcessID();
-
- /**
- * Get memory endianess.
- * @return true if memory id big-endian.
- */
- boolean isBigEndian();
-
- /**
- * Get memory address size.
- * @return number of bytes used to store memory address value.
- */
- int getAddressSize();
-
- /**
- * Get memory context name.
- * The name can be used for UI purposes.
- * @return context name.
- */
- String getName();
-
- /**
- * Get lowest address (inclusive) which is valid for the context.
- * @return lowest address.
- */
- Number getStartBound();
-
- /**
- * Get highest address (inclusive) which is valid for the context.
- * @return highest address.
- */
- Number getEndBound();
-
- /**
- * Get the access types allowed for this context.
- * @return collection of access type names.
- */
- Collection<String> getAccessTypes();
-
- /**
- * Get context properties.
- * @return all available context properties.
- */
- Map<String,Object> getProperties();
-
- /**
- * Set target memory.
- * If 'word_size' is 0 it means client does not care about word size.
- */
- IToken set(Number addr, int word_size, byte[] buf,
- int offs, int size, int mode, DoneMemory done);
-
- /**
- * Read target memory.
- */
- IToken get(Number addr, int word_size, byte[] buf,
- int offs, int size, int mode, DoneMemory done);
-
- /**
- * Fill target memory with given pattern.
- * 'size' is number of bytes to fill.
- */
- IToken fill(Number addr, int word_size, byte[] value,
- int size, int mode, DoneMemory done);
- }
-
- /**
- * Client call back interface for set(), get() and fill() commands.
- */
- interface DoneMemory {
- public void doneMemory(IToken token, MemoryError error);
- }
-
- class MemoryError extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public MemoryError(String msg) {
- super(msg);
- }
- }
-
- /**
- * ErrorOffset interface can be implemented by MemoryError object,
- * which is returned by get, set and fill commands.
- *
- * get/set/fill () returns this exception when reading failed
- * for some but not all bytes, and MODE_CONTINUEONERROR
- * has been set in mode. (For example, when only part of the request
- * translates to valid memory addresses.)
- * Exception.getMessage can be used for generalized message of the
- * possible reasons of partial memory operation.
- */
- interface ErrorOffset {
-
- // Error may have per byte information
- final static int
- BYTE_VALID = 0x00,
- BYTE_UNKNOWN = 0x01, // e.g. out of range
- BYTE_INVALID = 0x02,
- BYTE_CANNOT_READ = 0x04,
- BYTE_CANNOT_WRITE = 0x08;
-
- int getStatus(int offset);
-
- /**
- * Returns the detail message string about the
- * byte associated with specified location.
- * @return the detail error message string.
- */
- String getMessage(int offset);
-
- }
-
- /**
- * Add memory service event listener.
- * @param listener - event listener implementation.
- */
- void addListener(MemoryListener listener);
-
- /**
- * Remove memory service event listener.
- * @param listener - event listener implementation.
- */
- void removeListener(MemoryListener listener);
-
- /**
- * Memory event listener is notified when memory context hierarchy
- * changes, and when memory is modified by memory service commands.
- */
- interface MemoryListener {
-
- /**
- * Called when a new memory access context(s) is created.
- */
- void contextAdded(MemoryContext[] contexts);
-
- /**
- * Called when a memory access context(s) properties changed.
- */
- void contextChanged(MemoryContext[] contexts);
-
- /**
- * Called when memory access context(s) is removed.
- */
- void contextRemoved(String[] context_ids);
-
- /**
- * Called when target memory content was changed and clients
- * need to update themselves. Clients, at least, should invalidate
- * corresponding cached memory data.
- * Not every change is notified - it is not possible,
- * only those, which are not caused by normal execution of the debuggee.
- * ‘addr’ and ‘size’ can be null if unknown.
- */
- void memoryChanged(String context_id, Number[] addr, long[] size);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IProcesses.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IProcesses.java
deleted file mode 100644
index b8d530e82..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IProcesses.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.services;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-
-/**
- * IProcesses service provides access to the target OS's process
- * information, allows to start and terminate a process, and allows
- * to attach and detach a process for debugging. Debug services,
- * like IMemory and IRunControl, require a process to be attached
- * before they can access it.
- *
- * If a process is started by this service, its standard input/output streams are
- * available for client to read/write using Streams service. Stream type of such
- * streams is set to "Processes".
- */
-public interface IProcesses extends IService {
-
- static final String NAME = "Processes";
-
- /**
- * Retrieve context info for given context ID.
- * A context corresponds to an execution thread, process, address space, etc.
- * Context IDs are valid across TCF services, so it is allowed to issue
- * 'IProcesses.getContext' command with a context that was obtained,
- * for example, from Memory service.
- * However, 'Processes.getContext' is supposed to return only process specific data,
- * If the ID is not a process ID, 'IProcesses.getContext' may not return any
- * useful information
- *
- * @param id – context ID.
- * @param done - call back interface called when operation is completed.
- */
- IToken getContext(String id, DoneGetContext done);
-
- /**
- * Client call back interface for getContext().
- */
- interface DoneGetContext {
- /**
- * Called when context data retrieval is done.
- * @param error – error description if operation failed, null if succeeded.
- * @param context – context data.
- */
- void doneGetContext(IToken token, Exception error, ProcessContext context);
- }
-
- /**
- * Retrieve children of given context.
- *
- * @param parent_context_id – parent context ID. Can be null –
- * to retrieve top level of the hierarchy, or one of context IDs retrieved
- * by previous getContext or getChildren commands.
- * @param attached_only - if true return only attached process IDs.
- * @param done - call back interface called when operation is completed.
- */
- IToken getChildren(String parent_context_id, boolean attached_only, DoneGetChildren done);
-
- /**
- * Client call back interface for getChildren().
- */
- interface DoneGetChildren {
- /**
- * Called when context list retrieval is done.
- * @param error – error description if operation failed, null if succeeded.
- * @param context_ids – array of available context IDs.
- */
- void doneGetChildren(IToken token, Exception error, String[] context_ids);
- }
-
- /**
- * Context property names.
- */
- static final String
- /** The TCF context ID */
- PROP_ID = "ID",
-
- /** The TCF parent context ID */
- PROP_PARENTID = "ParentID",
-
- /** Is the context attached */
- PROP_ATTACHED = "Attached",
-
- /** Can terminate the context */
- PROP_CAN_TERMINATE = "CanTerminate",
-
- /** Process name. Client UI can show this name to a user */
- PROP_NAME = "Name",
-
- /** Process standard input stream ID */
- PROP_STDIN_ID = "StdInID",
-
- /** Process standard output stream ID */
- PROP_STDOUT_ID = "StdOutID",
-
- /** Process standard error stream ID */
- PROP_STDERR_ID = "StdErrID";
-
- interface ProcessContext {
-
- /**
- * Get context ID.
- * Same as getProperties().get(“ID”)
- */
- String getID();
-
- /**
- * Get parent context ID.
- * Same as getProperties().get(“ParentID”)
- */
- String getParentID();
-
- /**
- * Get process name.
- * Client UI can show this name to a user.
- * Same as getProperties().get(“Name”)
- */
- String getName();
-
- /**
- * Utility method to read context property PROP_ATTACHED.
- * Services like IRunControl, IMemory, IBreakpoints work only with attached processes.
- * @return value of PROP_ATTACHED.
- */
- boolean isAttached();
-
- /**
- * Utility method to read context property PROP_CAN_TERMINATE.
- * @return value of PROP_CAN_TERMINATE.
- */
- boolean canTerminate();
-
- /**
- * Get all available context properties.
- * @return Map 'property name' -> 'property value'
- */
- Map<String, Object> getProperties();
-
- /**
- * Attach debugger to a process.
- * Services like IRunControl, IMemory, IBreakpoints work only with attached processes.
- * @param done - call back interface called when operation is completed.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken attach(DoneCommand done);
-
- /**
- * Detach debugger from a process.
- * Process execution will continue without debugger supervision.
- * @param done - call back interface called when operation is completed.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken detach(DoneCommand done);
-
- /**
- * Terminate a process.
- * @param done - call back interface called when operation is completed.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken terminate(DoneCommand done);
- }
-
- /**
- * Call-back interface to be called when command is complete.
- */
- interface DoneCommand {
- void doneCommand(IToken token, Exception error);
- }
-
- /**
- * Signal property names used by "getSignalList" command.
- */
- static final String
- /** Number, bit position in the signal mask */
- SIG_INDEX = "Index",
-
- /** String, signal name, for example "SIGHUP" */
- SIG_NAME = "Name",
-
- /** Number, signal code, as defined by OS */
- SIG_CODE = "Code",
-
- /** String, human readable description of the signal */
- SIG_DESCRIPTION = "Description";
-
- /**
- * Get list of signals that can be send to the process.
- * @param done - call back interface called when operation is completed.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken getSignalList(String context_id, DoneGetSignalList done);
-
- /**
- * Call-back interface to be called when "getSignalList" command is complete.
- */
- interface DoneGetSignalList {
- void doneGetSignalList(IToken token, Exception error, Collection<Map<String,Object>> list);
- }
-
- /**
- * Get process or thread signal mask.
- * Bits in the mask control how signals should be handled by debug agent.
- * When new context is created it inherits the mask from its parent.
- * If context is not attached the command will return an error.
- * @param done - call back interface called when operation is completed.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken getSignalMask(String context_id, DoneGetSignalMask done);
-
- /**
- * Call-back interface to be called when "getSignalMask" command is complete.
- */
- interface DoneGetSignalMask {
- /**
- * @param token - command handle.
- * @param dont_stop - bit-set of signals that should suspend execution of the context.
- * @param dont_pass - bit-set of signals that should not be delivered to the context.
- * @param pending - bit-set of signals that are generated but not delivered yet.
- * Note: "pending" is meaningful only if the context is suspended.
- */
- void doneGetSignalMask(IToken token, Exception error, int dont_stop, int dont_pass, int pending);
- }
-
- /**
- * Set process or thread signal mask.
- * Bits in the mask control how signals should be handled by debug agent.
- * If context is not attached the command will return an error.
- * @param dont_stop - bit-set of signals that should not suspend execution of the context.
- * By default, debugger suspends a context before it receives a signal.
- * @param dont_pass - bit-set of signals that should not be delivered to the context.
- * @param done - call back interface called when operation is completed.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken setSignalMask(String context_id, int dont_stop, int dont_pass, DoneCommand done);
-
- /**
- * Send a signal to a process or thread.
- * @param context_id - context ID.
- * @param signal - signal code.
- * @param done - call back interface called when operation is completed.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken signal(String context_id, long signal, DoneCommand done);
-
- /**
- * Get default set of environment variables used to start a new process.
- * @param done - call back interface called when operation is completed.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken getEnvironment(DoneGetEnvironment done);
-
- /**
- * Call-back interface to be called when "getEnvironment" command is complete.
- */
- interface DoneGetEnvironment {
- void doneGetEnvironment(IToken token, Exception error, Map<String,String> environment);
- }
-
- /**
- * Start a new process on remote machine.
- * @param directory - initial value of working directory for the process.
- * @param file - process image file.
- * @param command_line - command line arguments for the process.
- * @param environment - map of environment variables for the process,
- * if null then default set of environment variables will be used.
- * @param attach - if true debugger should be attached to the process.
- * @param done - call back interface called when operation is completed.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken start(String directory, String file,
- String[] command_line, Map<String,String> environment,
- boolean attach, DoneStart done);
-
- /**
- * Call-back interface to be called when "start" command is complete.
- */
- interface DoneStart {
- void doneStart(IToken token, Exception error, ProcessContext process);
- }
-
- /**
- * Add processes service event listener.
- * @param listener - event listener implementation.
- */
- void addListener(ProcessesListener listener);
-
- /**
- * Remove processes service event listener.
- * @param listener - event listener implementation.
- */
- void removeListener(ProcessesListener listener);
-
- /**
- * Process event listener is notified when a process exits.
- * Event are reported only for processes that were started by 'start' command.
- */
- interface ProcessesListener {
-
- /**
- * Called when a process exits.
- * @param process_id - process context ID
- * @param exit_code - process exit code
- */
- void exited(String process_id, int exit_code);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRegisters.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRegisters.java
deleted file mode 100644
index 1e0abee4c..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRegisters.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.services;
-
-import java.util.Collection;
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-
-/**
- * IRegisters service provides access to target CPU register values and properties.
- */
-public interface IRegisters extends IService {
-
- static final String NAME = "Registers";
-
- /**
- * Context property names.
- */
- static final String
- PROP_ID = "ID", /** String, ID of the context */
- PROP_PARENT_ID = "ParentID", /** String, ID of a parent context */
- PROP_PROCESS_ID = "ProcessID", /** String, process ID */
- PROP_NAME = "Name", /** String, context name */
- PROP_DESCRIPTION = "Description", /** String, context description */
- PROP_SIZE = "Size", /** Number, context size in bytes. Byte arrays in get/set commands should be same size */
- PROP_READBLE = "Readable", /** Boolean, true if context value can be read */
- PROP_READ_ONCE = "ReadOnce", /** Boolean, true if reading the context (register) destroys its current value */
- PROP_WRITEABLE = "Writeable", /** Boolean, true if context value can be written */
- PROP_WRITE_ONCE = "WriteOnce", /** Boolean, true if register value can not be overwritten - every write counts */
- PROP_SIDE_EFFECTS = "SideEffects", /** Boolean, true if writing the context can change values of other registers */
- PROP_VOLATILE = "Volatile", /** Boolean, true if the register value can change even when target is stopped */
- PROP_FLOAT = "Float", /** Boolean, true if the register value is a floating-point value */
- PROP_BIG_ENDIAN = "BigEndian", /** Boolean, true if big endian */
- PROP_LEFT_TO_RIGHT = "LeftToRight", /** Boolean, true if the lowest numbered bit should be shown to user as the left-most bit */
- PROP_FIST_BIT = "FirstBit", /** Number, bit numbering base (0 or 1) to use when showing bits to user */
- PROP_BITS = "Bits", /** Number, if context is a bit field, contains the field bit numbers in the parent context */
- PROP_VALUES = "Values", /** Array of Map, predefined names (mnemonics) for some of context values */
- PROP_MEMORY_ADDRESS = "MemoryAddress", /** Number, the address of a memory mapped register */
- PROP_MEMORY_CONTEXT = "MemoryContext", /** String, the context ID of a memory context in which a memory mapped register is located */
- PROP_CAN_SEARCH = "CanSearch", /** Array of String, a list of attribute names which can be searched for starting on this context */
- PROP_ROLE = "Role"; /** String, the role the register plays in a program execution */
-
- /**
- * Values of context property "Role".
- */
- static final String
- ROLE_PC = "PC", /** Program counter. Defines instruction to execute next */
- ROLE_SP = "SP", /** Register defining the current stack pointer location */
- ROLE_FP = "FP", /** Register defining the current frame pointer location */
- ROLE_RET = "RET", /** Register used to store the return address for calls */
- ROLE_CORE = "CORE"; /** Indicates register or register groups which belong to the core state */
-
- /**
- * Search filter properties.
- */
- static final String
- SEARCH_NAME = "Name", /** The name of the property this filter applies too */
- SEARCH_EQUAL_VALUE = "EqualValue"; /** The value which is searched for */
-
- /**
- * Retrieve context info for given context ID.
- *
- * @param id – context ID.
- * @param done - call back interface called when operation is completed.
- */
- IToken getContext(String id, DoneGetContext done);
-
- /**
- * Client call back interface for getContext().
- */
- interface DoneGetContext {
- /**
- * Called when context data retrieval is done.
- * @param token - command handle
- * @param error – error description if operation failed, null if succeeded.
- * @param context – context data.
- */
- void doneGetContext(IToken token, Exception error, RegistersContext context);
- }
-
- /**
- * Retrieve contexts available for registers commands.
- * A context corresponds to an execution thread, stack frame, registers group, etc.
- * A context can belong to a parent context. Contexts hierarchy can be simple
- * plain list or it can form a tree. It is up to target agent developers to choose
- * layout that is most descriptive for a given target. Context IDs are valid across
- * all services. In other words, all services access same hierarchy of contexts,
- * with same IDs, however, each service accesses its own subset of context's
- * attributes and functionality, which is relevant to that service.
- *
- * @param parent_context_id – parent context ID. Can be null –
- * to retrieve top level of the hierarchy, or one of context IDs retrieved
- * by previous getChildren commands.
- * @param done - call back interface called when operation is completed.
- */
- IToken getChildren(String parent_context_id, DoneGetChildren done);
-
- /**
- * Client call back interface for getChildren().
- */
- interface DoneGetChildren {
- /**
- * Called when context list retrieval is done.
- * @param token - command handle
- * @param error – error description if operation failed, null if succeeded.
- * @param context_ids – array of available context IDs.
- */
- void doneGetChildren(IToken token, Exception error, String[] context_ids);
- }
-
- /**
- * RegistersContext objects represent register groups, registers and bit fields.
- */
- interface RegistersContext {
- /**
- * Get Context ID.
- * @return context ID.
- */
- String getID();
-
- /**
- * Get parent context ID.
- * @return parent context ID.
- */
- String getParentID();
-
- /**
- * Get process ID, if applicable.
- * @return process ID.
- */
- String getProcessID();
-
- /**
- * Get context (register, register group, bit field) name.
- * @return context name.
- */
- String getName();
-
- /**
- * Get context description.
- * @return context description.
- */
- String getDescription();
-
- /**
- * Get context size in bytes.
- * Byte arrays in get()/set() methods should be same size.
- * Hardware register can be smaller then this size, for example in case
- * when register size is not an even number of bytes. In such case implementation
- * should add/remove padding that consist of necessary number of zero bits.
- * @return context size in bytes.
- */
- int getSize();
-
- /**
- * Check if context value can be read.
- * @return true if can read value of the context.
- */
- boolean isReadable();
-
- /**
- * Check if reading the context (register) destroys its current value -
- * it can be read only once.
- * @return true if read-once register.
- */
- boolean isReadOnce();
-
- /**
- * Check if context value can be written.
- * @return true if can write value of the context.
- */
- boolean isWriteable();
-
- /**
- * Check if register value can not be overwritten - every write counts.
- * @return true if write-once register.
- */
- boolean isWriteOnce();
-
- /**
- * Check if writing the context can change values of other registers.
- * @return true if has side effects.
- */
- boolean hasSideEffects();
-
- /**
- * Check if the register value can change even when target is stopped.
- * @return true if the register value can change at any time.
- */
- boolean isVolatile();
-
- /**
- * Check if the register value is a floating-point value.
- * @return true if a floating-point register.
- */
- boolean isFloat();
-
- /**
- * Check endianess of the context.
- * Big endian means decreasing numeric significance with increasing bit number.
- * The endianess is used to encode and decode values of get, getm, set and setm commands.
- * @return true if big endian.
- */
- boolean isBigEndian();
-
- /**
- * Check if the lowest numbered bit (i.e. bit #0 or bit #1 depending on
- * getFirstBitNumber() value) should be shown to user as the left-most bit or
- * the right-most bit.
- * @return true if the first bit is left-most bit.
- */
- boolean isLeftToRight();
-
- /**
- * If the context has bit field children, bit positions of the fields
- * can be zero-based or 1-based.
- * @return first bit position - 0 or 1.
- */
- int getFirstBitNumber();
-
- /**
- * If context is a bit field, get the field bit numbers in parent context.
- * @return array of bit numbers.
- */
- int[] getBitNumbers();
-
- /**
- * A context can have predefined names (mnemonics) for some its values.
- * This method returns a list of such named values.
- * @return array of named values or null.
- */
- NamedValue[] getNamedValues();
-
- /**
- * Get the address of a memory mapped register.
- * @return address.
- */
- Number getMemoryAddress();
-
- /**
- * Get the context ID of a memory context in which a memory mapped register is located.
- * @return memory context ID.
- */
- String getMemoryContext();
-
- /**
- * Get a list of property names which can be searched for starting on this context
- * @return collection of property names.
- */
- Collection<String> canSearch();
-
- /**
- * Get the role the register plays in a program execution.
- * @return role name.
- */
- String getRole();
-
- /**
- * Get complete map of context properties.
- * @return map of all available context properties.
- */
- Map<String,Object> getProperties();
-
- /**
- * Read value of the context.
- * @param done - call back object.
- * @return - pending command handle.
- */
- IToken get(DoneGet done);
-
- /**
- * Set value of the context.
- * @param value - value to write into the context.
- * @param done - call back object.
- * @return - pending command handle.
- */
- IToken set(byte[] value, DoneSet done);
-
- /**
- * Search register contexts that passes given search filter.
- * Search is only supported for properties listed in the "CanSearch" property.
- * @param filter - properties bag that defines search filter.
- * @param done - call back object.
- * @return - pending command handle.
- */
- IToken search(Map<String,Object> filter, DoneSearch done);
- }
-
- /**
- * A register context can have predefined names (mnemonics) for some its values.
- * NamedValue objects represent such values.
- */
- interface NamedValue {
- /**
- * Get value associated with the name.
- * @return the value as an array of bytes.
- */
- byte[] getValue();
-
- /**
- * Get name (mnemonic) of the value.
- * @return value name.
- */
- String getName();
-
- /**
- * Get human readable description of the value.
- * @return value description.
- */
- String getDescription();
- }
-
- /**
- * Read values of multiple locations in registers.
- * @param locs - array of data locations.
- * @param done - call back object.
- * @return - pending command handle.
- */
- IToken getm(Location[] locs, DoneGet done);
-
- /**
- * Set values of multiple locations in registers.
- * @param locs - array of data locations.
- * @param value - value to write into the context.
- * @param done - call back object.
- * @return - pending command handle.
- */
- IToken setm(Location[] locs, byte[] value, DoneSet done);
-
- /**
- * Class Location represents value location in register context
- */
- final class Location {
- /** Register context ID */
- public final String id;
-
- /** offset in the context, in bytes */
- public final int offs;
-
- /** value size in byte */
- public final int size;
-
- public Location(String id, int offs, int size) {
- this.id = id;
- this.offs = offs;
- this.size = size;
- }
- }
-
- /**
- * 'get' command call back interface.
- */
- interface DoneGet {
- /**
- * Called when value retrieval is done.
- * @param token - command handle
- * @param error – error description if operation failed, null if succeeded.
- * @param value – context value as array of bytes.
- */
- void doneGet(IToken token, Exception error, byte[] value);
- }
-
- /**
- * 'set' command call back interface.
- */
- interface DoneSet {
- /**
- * Called when value setting is done.
- * @param token - command handle.
- * @param error – error description if operation failed, null if succeeded.
- */
- void doneSet(IToken token, Exception error);
- }
-
- /**
- * 'search' command call back interface.
- */
- interface DoneSearch {
- /**
- * Called when context search is done.
- * @param token - command handle.
- * @param error – error description if operation failed, null if succeeded.
- * @param paths - array of paths to each context with properties matching the filter
- */
- void doneSearch(IToken token, Exception error, String[][] paths);
- }
-
- /**
- * Add registers service event listener.
- * @param listener - event listener implementation.
- */
- void addListener(RegistersListener listener);
-
- /**
- * Remove registers service event listener.
- * @param listener - event listener implementation.
- */
- void removeListener(RegistersListener listener);
-
- /**
- * Registers event listener is notified when registers context hierarchy
- * changes, and when a register is modified by the service commands.
- */
- interface RegistersListener {
-
- /**
- * Called when register context properties changed.
- * Most targets have static set of registers and register properties.
- * Such targets never generate this event. However, some targets,
- * for example, JTAG probes, allow user to modify register definitions.
- * Clients should flush all cached register context data.
- */
- void contextChanged();
-
- /**
- * Called when register content was changed and clients
- * need to update themselves. Clients, at least, should invalidate
- * corresponding cached registers data.
- * Not every change is notified - it is not possible,
- * only those, which are not caused by normal execution of the debuggee.
- * At least, changes caused by "set" command should be notified.
- * @param id - register context ID.
- */
- void registerChanged(String id);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRunControl.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRunControl.java
deleted file mode 100644
index d7db79ddc..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IRunControl.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.services;
-
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-
-public interface IRunControl extends IService {
-
- static final String NAME = "RunControl";
-
- /**
- * Context property names.
- */
- static final String
- PROP_ID = "ID",
- PROP_PARENT_ID = "ParentID",
- PROP_PROCESS_ID = "ProcessID",
- PROP_IS_CONTAINER = "IsContainer",
- PROP_HAS_STATE = "HasState",
- PROP_CAN_RESUME = "CanResume",
- PROP_CAN_COUNT = "CanCount",
- PROP_CAN_SUSPEND = "CanSuspend",
- PROP_CAN_TERMINATE = "CanTerminate";
-
- /**
- * Context resume modes.
- */
- static final int
- RM_RESUME = 0,
- RM_STEP_OVER = 1,
- RM_STEP_INTO = 2,
- RM_STEP_OVER_LINE = 3,
- RM_STEP_INTO_LINE = 4,
- RM_STEP_OUT = 5,
- RM_REVERSE_RESUME = 6,
- RM_REVERSE_STEP_OVER = 7,
- RM_REVERSE_STEP_INTO = 8,
- RM_REVERSE_STEP_OVER_LINE = 9,
- RM_REVERSE_STEP_INTO_LINE = 10,
- RM_REVERSE_STEP_OUT = 11;
-
- /**
- * State change reason of a context.
- * Reason can be any text, but if it is one of predefined strings,
- * a generic client might be able to handle it better.
- */
- static final String
- REASON_USER_REQUEST = "Suspended",
- REASON_STEP = "Step",
- REASON_BREAKPOINT = "Breakpoint",
- REASON_EXCEPTION = "Exception",
- REASON_CONTAINER = "Container",
- REASON_WATCHPOINT = "Watchpoint",
- REASON_SIGNAL = "Signal",
- REASON_SHAREDLIB = "Shared Library",
- REASON_ERROR = "Error";
-
- /**
- * Retrieve context properties for given context ID.
- *
- * @param id – context ID.
- * @param done - callback interface called when operation is completed.
- */
- IToken getContext(String id, DoneGetContext done);
-
- /**
- * Client callback interface for getContext().
- */
- interface DoneGetContext {
- /**
- * Called when context data retrieval is done.
- * @param error – error description if operation failed, null if succeeded.
- * @param context – context data.
- */
- void doneGetContext(IToken token, Exception error, RunControlContext context);
- }
-
- /**
- * Retrieve children of given context.
- *
- * @param parent_context_id – parent context ID. Can be null –
- * to retrieve top level of the hierarchy, or one of context IDs retrieved
- * by previous getContext or getChildren commands.
- * @param done - callback interface called when operation is completed.
- */
- IToken getChildren(String parent_context_id, DoneGetChildren done);
-
- /**
- * Client callback interface for getChildren().
- */
- interface DoneGetChildren {
- /**
- * Called when context list retrieval is done.
- * @param error – error description if operation failed, null if succeeded.
- * @param context_ids – array of available context IDs.
- */
- void doneGetChildren(IToken token, Exception error, String[] context_ids);
- }
-
- /**
- * A context corresponds to an execution thread, process, address space, etc.
- * A context can belong to a parent context. Contexts hierarchy can be simple
- * plain list or it can form a tree. It is up to target agent developers to choose
- * layout that is most descriptive for a given target. Context IDs are valid across
- * all services. In other words, all services access same hierarchy of contexts,
- * with same IDs, however, each service accesses its own subset of context's
- * attributes and functionality, which is relevant to that service.
- */
- interface RunControlContext {
-
- /**
- * Retrieve context ID.
- * Same as getProperties().get(“ID”)
- */
- String getID();
-
- /**
- * Retrieve parent context ID.
- * Same as getProperties().get(“ParentID”)
- */
- String getParentID();
-
- /**
- * Get context properties. See PROP_* definitions for property names.
- * Context properties are read only, clients should not try to modify them.
- * @return Map of context properties.
- */
- Map<String,Object> getProperties();
-
- /**
- * Utility method to read context property PROP_IS_CONTAINER.
- * Executing resume or suspend command on a container causes all its children to resume or suspend.
- * @return value of PROP_IS_CONTAINER.
- */
- boolean isContainer();
-
- /**
- * Utility method to read context property PROP_HAS_STATE.
- * Only context that has a state can be resumed or suspended.
- * @return value of PROP_HAS_STATE.
- */
- boolean hasState();
-
- /**
- * Utility method to read context property PROP_CAN_SUSPEND.
- * Value 'true' means suspend command is supported by the context,
- * however the method does not check that the command can be executed successfully in
- * the current state of the context. For example, the command still can fail if context is
- * already suspended.
- * @return value of PROP_CAN_SUSPEND.
- */
- boolean canSuspend();
-
- /**
- * Utility method to read a 'mode' bit in context property PROP_CAN_RESUME.
- * Value 'true' means resume command is supported by the context,
- * however the method does not check that the command can be executed successfully in
- * the current state of the context. For example, the command still can fail if context is
- * already resumed.
- * @param mode - resume mode, see RM_*.
- * @return value of requested bit of PROP_CAN_RESUME.
- */
- boolean canResume(int mode);
-
- /**
- * Utility method to read a 'mode' bit in context property PROP_CAN_COUNT.
- * Value 'true' means resume command with count other then 1 is supported by the context,
- * however the method does not check that the command can be executed successfully in
- * the current state of the context. For example, the command still can fail if context is
- * already resumed.
- * @param mode - resume mode, see RM_*.
- * @return value of requested bit of PROP_CAN_COUNT.
- */
- boolean canCount(int mode);
-
- /**
- * Utility method to read context property PROP_CAN_TERMINATE.
- * Value 'true' means terminate command is supported by the context,
- * however the method does not check that the command can be executed successfully in
- * the current state of the context. For example, the command still can fail if context is
- * already exited.
- * @return value of PROP_CAN_SUSPEND.
- */
- boolean canTerminate();
-
- /**
- * Send a command to retrieve current state of a context.
- * @param done - command result call back object.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken getState(DoneGetState done);
-
- /**
- * Send a command to suspend a context.
- * Also suspends children if context is a container.
- * @param done - command result call back object.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken suspend(DoneCommand done);
-
- /**
- * Send a command to resume a context.
- * Also resumes children if context is a container.
- * @param mode - defines how to resume the context, see RM_*.
- * @param count - if mode implies stepping, defines how many steps to perform.
- * @param done - command result call back object.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken resume(int mode, int count, DoneCommand done);
-
- /**
- * Send a command to terminate a context.
- * @param done - command result call back object.
- * @return pending command handle, can be used to cancel the command.
- */
- IToken terminate(DoneCommand done);
- }
-
- class RunControlError extends Exception {
-
- private static final long serialVersionUID = 1L;
- }
-
- interface DoneGetState {
- void doneGetState(IToken token, Exception error, boolean suspended, String pc,
- String reason, Map<String,Object> params);
- }
-
- interface DoneCommand {
- /**
- * Called when run control command execution is complete.
- * @param token - pending command handle.
- * @param error - command execution error or null.
- */
- void doneCommand(IToken token, Exception error);
- }
-
- /**
- * Add run control event listener.
- * @param listener - run control event listener to add.
- */
- void addListener(RunControlListener listener);
-
- /**
- * Remove run control event listener.
- * @param listener - run control event listener to remove.
- */
- void removeListener(RunControlListener listener);
-
- /**
- * Service events listener interface.
- */
- interface RunControlListener {
-
- /**
- * Called when new contexts are created.
- * @param contexts - array of new context properties.
- */
- void contextAdded(RunControlContext contexts[]);
-
- /**
- * Called when a context properties changed.
- * @param contexts - array of new context properties.
- */
- void contextChanged(RunControlContext contexts[]);
-
- /**
- * Called when contexts are removed.
- * @param context_ids - array of removed context IDs.
- */
- void contextRemoved(String context_ids[]);
-
- /**
- * Called when a thread is suspended.
- * @param context - ID of a context that was suspended.
- * @param pc - program counter of the context, can be null.
- * @param reason - human readable description of suspend reason.
- * @param params - additional, target specific data about suspended context.
- */
- void contextSuspended(String context, String pc,
- String reason, Map<String,Object> params);
-
- /**
- * Called when a thread is resumed.
- * @param context - ID of a context that was resumed.
- */
- void contextResumed(String context);
-
- /**
- * Called when target simultaneously suspends multiple threads in a container
- * (process, core, etc.).
- *
- * @param context - ID of a context responsible for the event. It can be container ID or
- * any one of container children, for example, it can be thread that hit "suspend all" breakpoint.
- * Client expected to move focus (selection) to this context.
- * @param pc - program counter of the context.
- * @param reason - human readable description of suspend reason.
- * @param params - additional target specific data about suspended context.
- * @param suspended_ids - full list of all contexts that were suspended.
- */
- void containerSuspended(String context, String pc,
- String reason, Map<String,Object> params, String[] suspended_ids);
-
- /**
- * Called when target simultaneously resumes multiple threads in a container (process,
- * core, etc.).
- *
- * @param context_ids - full list of all contexts that were resumed.
- */
- void containerResumed(String[] context_ids);
-
- /**
- * Called when an exception is detected in a target thread.
- * @param context - ID of a context that caused an exception.
- * @param msg - human readable description of the exception.
- */
- void contextException(String context, String msg);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IStackTrace.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IStackTrace.java
deleted file mode 100644
index cba5b560c..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IStackTrace.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.services;
-
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-
-public interface IStackTrace extends IService {
-
- static final String NAME = "StackTrace";
-
- /**
- * Context property names.
- */
- static final String
- PROP_ID = "ID",
- PROP_PARENT_ID = "ParentID",
- PROP_PROCESS_ID = "ProcessID",
- PROP_NAME = "Name",
- PROP_FRAME_ADDRESS = "FP",
- PROP_RETURN_ADDRESS = "RP",
- PROP_INSTRUCTION_ADDRESS = "IP",
- PROP_ARGUMENTS_COUNT = "ArgsCnt",
- PROP_ARGUMENTS_ADDRESS = "ArgsAddr";
-
- /**
- * Retrieve context info for given context IDs.
- *
- * The command will fail if parent thread is not suspended.
- * Client can use Run Control service to suspend a thread.
- *
- * @param id – array of context IDs.
- * @param done - call back interface called when operation is completed.
- */
- IToken getContext(String[] id, DoneGetContext done);
-
- /**
- * Client call back interface for getContext().
- */
- interface DoneGetContext {
- /**
- * Called when context data retrieval is done.
- * @param error – error description if operation failed, null if succeeded.
- * @param context – array of context data or null if error.
- */
- void doneGetContext(IToken token, Exception error, StackTraceContext[] context);
- }
-
- /**
- * Retrieve stack trace context list.
- * Parent context usually corresponds to an execution thread.
- * Some targets have more then one stack. In such case children of a thread
- * are stacks, and stack frames are deeper in the hierarchy - they can be
- * retrieved with additional getChildren commands.
- *
- * The command will fail if parent thread is not suspended.
- * Client can use Run Control service to suspend a thread.
- *
- * @param parent_context_id – parent context ID.
- * @param done - call back interface called when operation is completed.
- */
- IToken getChildren(String parent_context_id, DoneGetChildren done);
-
- /**
- * Client call back interface for getChildren().
- */
- interface DoneGetChildren {
- /**
- * Called when context list retrieval is done.
- * @param error – error description if operation failed, null if succeeded.
- * @param context_ids – array of available context IDs.
- * Stack frames are ordered from stack bottom to top.
- */
- void doneGetChildren(IToken token, Exception error, String[] context_ids);
- }
-
- /**
- * StackTraceContext represents stack trace objects - stacks and stack frames.
- */
- interface StackTraceContext {
-
- /**
- * Get Context ID.
- * @return context ID.
- */
- String getID();
-
- /**
- * Get parent context ID.
- * @return parent context ID.
- */
- String getParentID();
-
- /**
- * Get context name - if context represents a stack.
- * @return context name or null.
- */
- String getName();
-
- /**
- * Get memory address of this frame.
- * @return address or null if not a stack frame.
- */
- Number getFrameAddress();
-
- /**
- * Get program counter saved in this stack frame -
- * it is address of instruction to be executed when the function returns.
- * @return return address or null if not a stack frame.
- */
- Number getReturnAddress();
-
- /**
- * Get address of the next instruction to be executed in this stack frame.
- * For top frame it is same as PC register value.
- * For other frames it is same as return address of the next frame.
- * @return instruction address or null if not a stack frame.
- */
- Number getInstructionAddress();
-
- /**
- * Get number of function arguments for this frame.
- * @return function arguments count.
- */
- int getArgumentsCount();
-
- /**
- * Get address of function arguments area in memory.
- * @return function arguments address or null if not available.
- */
- Number getArgumentsAddress();
-
- /**
- * Get complete map of context properties.
- * @return map of context properties.
- */
- Map<String,Object> getProperties();
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IStreams.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IStreams.java
deleted file mode 100644
index ded45744c..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IStreams.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.tm.tcf.services;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-/**
- * Streams service is a generic interface to support streaming of data between host and remote agents.
- *
- * The service supports:
- * 1. Asynchronous overlapped data streaming: multiple 'read' or 'write' command can be issued at same time, both peers
- * can continue data processing concurrently with data transmission.
- * 2. Multicast: multiple clients can receive data from same stream.
- * 3. Subscription model: clients are required to expressed interest in particular streams by subscribing for the service.
- * 4. Flow control: peers can throttle data flow of individual streams by delaying 'read' and 'write' commands.
- */
-public interface IStreams extends IService {
-
- /**
- * Service name.
- */
- static final String NAME = "Streams";
-
- /**
- * Clients can implement StreamsListener interface to be notified
- * when a stream is created or disposed. The interface is registered with 'subscribe' command.
- *
- * When new stream is created, client must decide if it is interested in that particular stream instance.
- * If not interested, client should send 'disconnect' command to allow remote peer to free resources and bandwidth.
- * If not disconnected, client is required to send 'read' commands as necessary to prevent stream buffer overflow.
- */
- interface StreamsListener {
-
- /**
- * Called when a new stream is created.
- * @param stream_type - source type of the stream.
- * @param stream_id - ID of the stream.
- */
- void created(String stream_type, String stream_id);
-
- /**
- * Called when a stream is disposed.
- * @param stream_type - source type of the stream.
- * @param stream_id - ID of the stream.
- */
- void disposed(String stream_type, String stream_id);
- }
-
- /**
- * Clients must subscribe for one or more stream types to be able to send or receive stream data.
- * Subscribers receive notifications when a stream of given type is created or disposed.
- * Subscribers are required to respond with 'read' or 'disconnect' commands as necessary.
- * @param stream_type - the stream source type.
- * @param listener - client implementation of StreamsListener interface.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken subscribe(String stream_type, StreamsListener listener, DoneSubscribe done);
-
- /**
- * Call back interface for 'subscribe' command.
- */
- interface DoneSubscribe {
- void doneSubscribe(IToken token, Exception error);
- }
-
- /**
- * Unsubscribe the client from given stream source type.
- * @param stream_type - the stream source type.
- * @param listener - client implementation of StreamsListener interface.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken unsubscribe(String stream_type, StreamsListener listener, DoneUnsubscribe done);
-
- /**
- * Call back interface for 'unsubscribe' command.
- */
- interface DoneUnsubscribe {
- void doneUnsubscribe(IToken token, Exception error);
- }
-
- /**
- * Read data from a stream. If stream buffer is empty, the command will wait until data is available.
- * Remote peer will continue to process other commands while 'read' command is pending.
- * Client can send more 'read' commands without waiting for the first command to complete.
- * Doing that improves communication channel bandwidth utilization.
- * Pending 'read' commands will be executed in same order as issued.
- * Client can delay sending of 'read' command if it is not ready to receive more data,
- * however, delaying for too long can cause stream buffer overflow and lost of data.
- * @param stream_id - ID of the stream.
- * @param size - max number of bytes to read.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken read(String stream_id, int size, DoneRead done);
-
- /**
- * Call back interface for 'read' command.
- */
- interface DoneRead {
- /**
- * Called when 'read' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- * @param lost_size - number of bytes that were lost because of buffer overflow.
- * 'lost_size' -1 means unknown number of bytes were lost.
- * if both 'lost_size' and 'data.length' are non-zero then lost bytes are considered
- * located right before read bytes.
- * @param data - bytes read from the stream.
- * @param eos - true if end of stream was reached.
- */
- void doneRead(IToken token, Exception error, int lost_size, byte[] data, boolean eos);
- }
-
- /**
- * Write data to a stream. If stream buffer is full, the command will wait until space is available.
- * Remote peer will continue to process other commands while 'write' command is pending.
- * Client can send more 'write' commands without waiting for the first command to complete.
- * Doing that improves communication channel bandwidth utilization.
- * Pending 'write' commands will be executed in same order as issued.
- * @param stream_id - ID of the stream.
- * @param buf - buffer that contains stream data.
- * @param offset - byte offset in the buffer.
- * @param size - number of bytes to write.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken write(String stream_id, byte[] buf, int offset, int size, DoneWrite done);
-
- /**
- * Call back interface for 'write' command.
- */
- interface DoneWrite {
- /**
- * Called when 'write' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- */
- void doneWrite(IToken token, Exception error);
- }
-
- /**
- * Send End Of Stream marker to a stream. No more writing to the stream is allowed after that.
- * @param stream_id - ID of the stream.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken eos(String stream_id, DoneEOS done);
-
- /**
- * Call back interface for 'eos' command.
- */
- interface DoneEOS {
- /**
- * Called when 'eos' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- */
- void doneEOS(IToken token, Exception error);
- }
-
- /**
- * Disconnect client from a stream.
- * @param stream_id - ID of the stream.
- * @param done - command result call back object.
- * @return - pending command handle.
- */
- IToken disconnect(String stream_id, DoneDisconnect done);
-
- /**
- * Call back interface for 'disconnect' command.
- */
- interface DoneDisconnect {
- /**
- * Called when 'disconnect' command is done.
- * @param token - command handle.
- * @param error - error object or null.
- */
- void doneDisconnect(IToken token, Exception error);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ISymbols.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ISymbols.java
deleted file mode 100644
index 0a6d24a7d..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ISymbols.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.tm.tcf.services;
-
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-public interface ISymbols extends IService {
-
- /**
- * Service name.
- */
- static final String NAME = "Symbols";
-
- enum SymbolClass {
- unknown, // unknown symbol class
- value, // constant value
- reference, // variable data object
- function, // function body
- type // a type
- }
-
- enum TypeClass {
- unknown, // unknown type class
- cardinal, // unsigned integer
- integer, // signed integer
- real, // float, double
- pointer, // pointer to anything.
- array, // array of anything.
- composite, // struct, union, or class.
- enumeration, // enumeration type.
- function // function type.
- }
-
- /**
- * Symbol context interface.
- */
- interface Symbol {
- /**
- * Get symbol ID.
- * @return symbol ID.
- */
- String getID();
-
- /**
- * Get execution context ID (thread or process) that owns this instance of a symbol.
- * @return execution context ID.
- */
- String getExeContextID();
-
- /**
- * Get symbol name.
- * @return symbol name or null.
- */
- String getName();
-
- /**
- * Get symbol class.
- * @return symbol class.
- */
- SymbolClass getSymbolClass();
-
- /**
- * Get symbol type class.
- * @return type class.
- */
- TypeClass getTypeClass();
-
- /**
- * Get type ID.
- * If the symbol is a type and not a 'typedef', return same as getID().
- * @return type ID.
- */
- String getTypeID();
-
- /**
- * Get base type ID.
- * If this symbol is a
- * pointer type - return pointed type;
- * array type - return element type;
- * function type - return function result type;
- * class type - return base class;
- * otherwise return null.
- * @return type ID.
- */
- String getBaseTypeID();
-
- /**
- * Get index type ID.
- * If this symbol is a
- * array type - return array index type;
- * otherwise return null.
- * @return type ID.
- */
- String getIndexTypeID();
-
- /**
- * Return value size of the symbol (or type).
- * @return size in bytes.
- */
- int getSize();
-
- /**
- * If symbol is an array type - return number of elements.
- * @return number of elements.
- */
- int getLength();
-
- /**
- * Return offset from 'this' for member of class, struct or union.
- * @return offset in bytes.
- */
- int getOffset();
-
- /**
- * Return address of the symbol.
- * @return address or null.
- */
- Number getAddress();
-
- /**
- * If symbol is a constant object, return its value.
- * @return symbol value as array of bytes.
- */
- byte[] getValue();
-
- /**
- * Get complete map of context properties.
- * @return map of context properties.
- */
- Map<String,Object> getProperties();
- }
-
- /**
- * Symbol context property names.
- */
- static final String
- PROP_ID = "ID",
- PROP_EXE_ID = "ExeID",
- PROP_NAME = "Name",
- PROP_SYMBOL_CLASS = "Class",
- PROP_TYPE_CLASS = "TypeClass",
- PROP_TYPE_ID = "TypeID",
- PROP_BASE_TYPE_ID = "BaseTypeID",
- PROP_INDEX_TYPE_ID = "IndexTypeID",
- PROP_SIZE = "Size",
- PROP_LENGTH = "Length",
- PROP_OFFSET = "Offset",
- PROP_ADDRESS = "Address",
- PROP_VALUE = "Value";
-
- /**
- * Retrieve symbol context info for given symbol ID.
- * @see Symbol
- *
- * @param id – symbol context ID.
- * @param done - call back interface called when operation is completed.
- * @return - pending command handle.
- */
- IToken getContext(String id, DoneGetContext done);
-
- /**
- * Client call back interface for getContext().
- */
- interface DoneGetContext {
- /**
- * Called when context data retrieval is done.
- * @param token - command handle
- * @param error – error description if operation failed, null if succeeded.
- * @param context – context properties.
- */
- void doneGetContext(IToken token, Exception error, Symbol context);
- }
-
- /**
- * Retrieve children IDs for given parent ID.
- * Meaning of the operation depends on parent kind:
- * 1. struct, union, or class type - get fields;
- * 2. enumeration type - get enumerators;
- *
- * @param parent_context_id – parent symbol context ID.
- * @param done - call back interface called when operation is completed.
- * @return - pending command handle.
- */
- IToken getChildren(String parent_context_id, DoneGetChildren done);
-
- /**
- * Client call back interface for getChildren().
- */
- interface DoneGetChildren {
- /**
- * Called when context list retrieval is done.
- * @param token - command handle
- * @param error – error description if operation failed, null if succeeded.
- * @param context_ids – array of available context IDs.
- */
- void doneGetChildren(IToken token, Exception error, String[] context_ids);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ISysMonitor.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ISysMonitor.java
deleted file mode 100644
index cd54d76ac..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ISysMonitor.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.services;
-
-import java.util.Map;
-
-import org.eclipse.tm.tcf.protocol.IService;
-import org.eclipse.tm.tcf.protocol.IToken;
-
-
-/**
- * This is optional service that can be implemented by a peer.
- * If implemented, the service can be used for monitoring system activity and utilization.
- * It provides list of running processes, different process attributes like command line, environment, etc.,
- * and some resource utilization data. The service can be used by a client to provide functionality
- * similar to Unix 'top' utility or Windows 'Task Manager'.
- */
-public interface ISysMonitor extends IService {
-
- static final String NAME = "SysMonitor";
-
- /**
- * Retrieve context info for given context ID.
- *
- * @param id – context ID.
- * @param done - callback interface called when operation is completed.
- */
- IToken getContext(String id, DoneGetContext done);
-
- /**
- * Client callback interface for getContext().
- */
- interface DoneGetContext {
- /**
- * Called when context data retrieval is done.
- * @param error – error description if operation failed, null if succeeded.
- * @param context – context data.
- */
- void doneGetContext(IToken token, Exception error, SysMonitorContext context);
- }
-
- /**
- * Retrieve children of given context.
- *
- * @param parent_context_id – parent context ID. Can be null –
- * to retrieve top level of the hierarchy, or one of context IDs retrieved
- * by previous getContext or getChildren commands.
- * @param done - callback interface called when operation is completed.
- */
- IToken getChildren(String parent_context_id, DoneGetChildren done);
-
- /**
- * Client callback interface for getChildren().
- */
- interface DoneGetChildren {
- /**
- * Called when context list retrieval is done.
- * @param error – error description if operation failed, null if succeeded.
- * @param context_ids – array of available context IDs.
- */
- void doneGetChildren(IToken token, Exception error, String[] context_ids);
- }
-
- /**
- * Context property names.
- */
- static final String
- /** The TCF context ID */
- PROP_ID = "ID",
-
- /** The TCF parent context ID */
- PROP_PARENTID = "ParentID",
-
- /** Current working directory of the process */
- PROP_CWD = "CWD",
-
- /** The process's root directory (as set by chroot) */
- PROP_ROOT = "Root",
-
- /** User ID of the process owner */
- PROP_UID = "UID",
-
- /** Group ID of the process owner */
- PROP_UGID = "UGID",
-
- /** User name of the process owner */
- PROP_USERNAME = "UserName",
-
- /** Group name of the process owner */
- PROP_GROUPNAME = "GroupName",
-
- /** System process ID */
- PROP_PID = "PID",
-
- /** Executable file of the process */
- PROP_FILE = "File",
-
- /** One character from the string "RSDZTW" where R is running, S is
- * sleeping in an interruptible wait, D is waiting in uninterruptible
- * disk sleep, Z is zombie, T is traced or stopped (on a signal), and W
- * is paging.*/
- PROP_STATE = "State",
-
- /** System ID of the parent process */
- PROP_PPID = "PPID",
-
- /** The process group ID of the process */
- PROP_PGRP = "PGRP",
-
- /** The session ID of the process */
- PROP_SESSION = "Session",
-
- /** The tty the process uses */
- PROP_TTY = "TTY",
-
- /** The process group ID of the process which currently owns the tty that
- * the process is connected to. */
- PROP_TGID = "TGID",
-
- /** ID of a process that has attached this process for tracing or debugging */
- PROP_TRACERPID = "TracerPID",
-
- /** The kernel flags word of the process. Details depend on the kernel */
- PROP_FLAGS = "Flags",
-
- /** The number of minor faults the process has made which have not
- * required loading a memory page from disk */
- PROP_MINFLT = "MinFlt",
-
- /** The number of minor faults that the process's waited-for children have made */
- PROP_CMINFLT = "CMinFlt",
-
- /** The number of major faults the process has made which have required
- * loading a memory page from disk */
- PROP_MAJFLT = "MajFlt",
-
- /** The number of major faults that the process's waited-for children
- * have made */
- PROP_CMAJFLT = "CMajFlt",
-
- /** The number of milliseconds that this process has been scheduled in user mode */
- PROP_UTIME = "UTime",
-
- /** The number of milliseconds that this process has been scheduled in kernel mode */
- PROP_STIME = "STime",
-
- /** The number of jiffies that this process's waited-for children have
- * been scheduled in user mode */
- PROP_CUTIME = "CUTime",
-
- /** The number of jiffies that this process's waited-for children have
- * been scheduled in user mode */
- PROP_CSTIME = "CSTime",
-
- /** The standard nice value */
- PROP_PRIORITY = "Priority",
-
- /** The nice value */
- PROP_NICE = "Nice",
-
- /** The time in milliseconds before the next SIGALRM is sent to the process
- * due to an interval timer */
- PROP_ITREALVALUE = "ITRealValue",
-
- /** The time in milliseconds the process started after system boot */
- PROP_STARTTIME = "StartTime",
-
- /** Virtual memory size in bytes */
- PROP_VSIZE = "VSize",
-
- /** Memory pages size in bytes */
- PROP_PSIZE = "PSize",
-
- /** Resident Set Size: number of pages the process has in real memory,
- * minus used for administrative purposes. This is just the pages which
- * count towards text, data, or stack space. This does not include
- * pages which have not been demand-loaded in, or which are swapped out */
- PROP_RSS = "RSS",
-
- /** Current limit in bytes on the rss of the process */
- PROP_RLIMIT = "RLimit",
-
- /** The address above which program text can run */
- PROP_CODESTART = "CodeStart",
-
- /** The address below which program text can run */
- PROP_CODEEND = "CodeEnd",
-
- /** The address of the start of the stack */
- PROP_STACKSTART = "StackStart",
-
- /** The bitmap of pending signals */
- PROP_SIGNALS = "Signals",
-
- /** The bitmap of blocked signals */
- PROP_SIGBLOCK = "SigBlock",
-
- /** The bitmap of ignored signals */
- PROP_SIGIGNORE = "SigIgnore",
-
- /** The bitmap of caught signals */
- PROP_SIGCATCH = "SigCatch",
-
- /** This is the "channel" in which the process is waiting. It is the
- * address of a system call, and can be looked up in a name list if you
- * need a textual name */
- PROP_WCHAN = "WChan",
-
- /** Number of pages swapped */
- PROP_NSWAP = "NSwap",
-
- /** Cumulative NSwap for child processes */
- PROP_CNSWAP = "CNSwap",
-
- /** Signal to be sent to parent when this process exits */
- PROP_EXITSIGNAL = "ExitSignal",
-
- /** CPU number last executed on */
- PROP_PROCESSOR = "Processor",
-
- /** Real-time scheduling priority */
- PROP_RTPRIORITY = "RTPriority",
-
- /** Scheduling policy */
- PROP_POLICY = "Policy";
-
-
- /**
- * A context corresponds to an execution thread, process, address space, etc.
- * A context can belong to a parent context. Contexts hierarchy can be simple
- * plain list or it can form a tree. It is up to target agent developers to choose
- * layout that is most descriptive for a given target. Context IDs are valid across
- * all services. In other words, all services access same hierarchy of contexts,
- * with same IDs, however, each service accesses its own subset of context's
- * attributes and functionality, which is relevant to that service.
- */
- interface SysMonitorContext {
-
- /**
- * Get context ID.
- * Same as getProperties().get(“ID”)
- */
- String getID();
-
- /**
- * Get parent context ID.
- * Same as getProperties().get(“ParentID”)
- */
- String getParentID();
-
- /**
- * Get process group ID.
- * Same as getProperties().get(“PGRP”)
- */
- long getPGRP();
-
- /**
- * Get process ID.
- * Same as getProperties().get(“PID”)
- */
- long getPID();
-
- /**
- * Get process parent ID.
- * Same as getProperties().get(“PPID”)
- */
- long getPPID();
-
- /**
- * Get process TTY group ID.
- * Same as getProperties().get(“TGID”)
- */
- long getTGID();
-
- /**
- * Get tracer process ID.
- * Same as getProperties().get(“TracerPID”)
- */
- long getTracerPID();
-
- /**
- * Get process owner user ID.
- * Same as getProperties().get(“UID”)
- */
- long getUID();
-
- /**
- * Get process owner user name.
- * Same as getProperties().get(“UserName”)
- */
- String getUserName();
-
- /**
- * Get process owner user group ID.
- * Same as getProperties().get(“UGID”)
- */
- long getUGID();
-
- /**
- * Get process owner user group name.
- * Same as getProperties().get(“GroupName”)
- */
- String getGroupName();
-
- /**
- * Get process state.
- * Same as getProperties().get(“State”)
- */
- String getState();
-
- /**
- * Get process virtual memory size in bytes.
- * Same as getProperties().get(“VSize”)
- */
- long getVSize();
-
- /**
- * Get process virtual memory page size in bytes.
- * Same as getProperties().get(“PSize”)
- */
- long getPSize();
-
- /**
- * Get number of memory pages in process resident set.
- * Same as getProperties().get(“RSS”)
- */
- long getRSS();
-
- /**
- * Get context executable file.
- * Same as getProperties().get(“File”)
- */
- String getFile();
-
- /**
- * Get context current file system root.
- * Same as getProperties().get(“Root”)
- */
- String getRoot();
-
- /**
- * Get context current working directory.
- * Same as getProperties().get(“CWD”)
- */
- String getCurrentWorkingDirectory();
-
- /**
- * Get all available context properties.
- * @return Map 'property name' -> 'property value'
- */
- Map<String,Object> getProperties();
- }
-
- /**
- * Get context command line.
- */
- IToken getCommandLine(String id, DoneGetCommandLine done);
-
- interface DoneGetCommandLine {
- void doneGetCommandLine(IToken token, Exception error, String[] cmd_line);
- }
-
- /**
- * Get context environment variables.
- */
- IToken getEnvironment(String id, DoneGetEnvironment done);
-
- interface DoneGetEnvironment {
- void doneGetEnvironment(IToken token, Exception error, String[] environment);
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFDataCache.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFDataCache.java
deleted file mode 100644
index 204f45c04..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFDataCache.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 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.tm.tcf.util;
-
-import java.util.HashSet;
-
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.Protocol;
-
-/**
- * Objects of this class are used to cache TCF remote data.
- * The cache is asynchronous state machine. The states are:
- * 1. Valid - cache is in sync with remote data, use getError() and getData() to get cached data;
- * 2. Invalid - cache is out of sync, start data retrieval by calling validate();
- * 3. Pending - cache is waiting result of a command that was sent to remote peer.
- * @param <V> - type of data to be stored in the cache.
- */
-public abstract class TCFDataCache<V> implements Runnable {
-
- private Throwable error;
- private boolean valid;
- private boolean posted;
- private V data;
-
- protected final IChannel channel;
- protected IToken command;
-
- private final HashSet<Runnable> waiting_list = new HashSet<Runnable>();
-
- public TCFDataCache(IChannel channel) {
- assert channel != null;
- this.channel = channel;
- }
-
- private void post() {
- if (posted) return;
- if (waiting_list.isEmpty()) return;
- Protocol.invokeLater(this);
- posted = true;
- }
-
- /**
- * @return true if cache contains up-to-date data (or data retrieval error).
- */
- public boolean isValid() {
- return valid;
- }
-
- /**
- * @return true if data retrieval command is in progress.
- */
- public boolean isPending() {
- return command != null;
- }
-
- /**
- * @return error object if data retrieval ended with an error, or null if retrieval was successful.
- * Note: It is prohibited to call this method when cache is not valid.
- */
- public Throwable getError() {
- assert valid;
- return error;
- }
-
- /**
- * @return cached data object.
- * Note: It is prohibited to call this method when cache is not valid.
- */
- public V getData() {
- assert Protocol.isDispatchThread();
- assert valid;
- return data;
- }
-
- /**
- * Notify waiting clients about cache state change and remove them from wait list.
- * It is responsibility of clients to check if the state change was one they are waiting for.
- */
- public void run() {
- assert Protocol.isDispatchThread();
- posted = false;
- Runnable[] arr = waiting_list.toArray(new Runnable[waiting_list.size()]);
- waiting_list.clear();
- for (Runnable r : arr) {
- if (r instanceof TCFDataCache<?> && ((TCFDataCache<?>)r).posted) continue;
- r.run();
- }
- }
-
- /**
- * Add a client call-back to cache wait list.
- * Client call-backs are activated when cache state changes.
- * Call-backs are removed from waiting list after that.
- * It is responsibility of clients to check if the state change was one they are waiting for.
- * @param cb - a call-back object
- */
- public void wait(Runnable cb) {
- assert Protocol.isDispatchThread();
- assert !valid;
- if (cb != null) waiting_list.add(cb);
- }
-
- /**
- * Initiate data retrieval if the cache is not valid.
- * @return true if the cache is already valid
- */
- public boolean validate() {
- assert Protocol.isDispatchThread();
- if (channel.getState() != IChannel.STATE_OPEN) {
- error = null;
- command = null;
- valid = true;
- data = null;
- }
- else {
- if (command != null) return false;
- if (!valid && !startDataRetrieval()) return false;
- }
- assert valid;
- assert command == null;
- post();
- return true;
- }
-
- /**
- * End cache pending state.
- * @param token - pending command handle.
- * @param error - data retrieval error or null
- * @param data - up-to-date data object
- */
- public void set(IToken token, Throwable error, V data) {
- assert Protocol.isDispatchThread();
- if (command != token) return;
- command = null;
- if (channel.getState() != IChannel.STATE_OPEN) data = null;
- this.error = error;
- this.data = data;
- valid = true;
- post();
- }
-
- /**
- * Force cache to become valid, cancel pending data retrieval if any.
- * @param data - up-to-date data object
- */
- public void reset(V data) {
- assert Protocol.isDispatchThread();
- if (command != null) {
- command.cancel();
- command = null;
- }
- this.data = data;
- error = null;
- valid = true;
- post();
- }
-
- /**
- * Invalidate the cache. If retrieval is in progress - let it continue.
- */
- public void reset() {
- assert Protocol.isDispatchThread();
- error = null;
- valid = false;
- data = null;
- post();
- }
-
- /**
- * Force cache to invalid state, cancel pending data retrieval if any.
- */
- public void cancel() {
- assert Protocol.isDispatchThread();
- if (command != null) {
- command.cancel();
- command = null;
- }
- error = null;
- valid = false;
- data = null;
- post();
- }
-
- @Override
- public String toString() {
- StringBuffer bf = new StringBuffer();
- bf.append('[');
- if (valid) bf.append("valid,");
- if (posted) bf.append("posted,");
- if (error != null) bf.append("error,");
- bf.append("data=");
- bf.append(data == null ? "null" : data.toString());
- bf.append(']');
- return bf.toString();
- }
-
- /**
- * Sub-classes should override this method to implement actual data retrieval logic.
- * @return true is all done, false if retrieval is in progress.
- */
- protected abstract boolean startDataRetrieval();
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFFileInputStream.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFFileInputStream.java
deleted file mode 100644
index a6ba47668..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFFileInputStream.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.protocol.Protocol;
-import org.eclipse.tm.tcf.services.IFileSystem;
-import org.eclipse.tm.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tm.tcf.services.IFileSystem.IFileHandle;
-
-/**
- * TCFFileInputStream is high performance InputStream implementation over TCF FileSystem service.
- * The class uses read-ahead buffers to achieve maximum throughput.
- *
- * @noextend This class is not intended to be subclassed by clients.
- */
-public final class TCFFileInputStream extends InputStream {
-
- private static final int MAX_READ_AHEAD = 8;
-
- private static class Buffer {
-
- final long offset;
-
- IToken token;
- byte[] buf;
- boolean eof;
-
- Buffer(long offset) {
- this.offset = offset;
- }
-
- @Override
- public String toString() {
- return "[" + offset + ":" + (buf == null ? "null" : Integer.toString(buf.length)) + "]";
- }
- }
-
- private final IFileHandle handle;
- private final IFileSystem fs;
- private final int buf_size;
- private long mark = 0;
- private long offset = 0;
- private Buffer buf;
- private boolean closed = false;
-
- private boolean suspend_read_ahead;
- private Runnable waiting_client;
- private final LinkedList<Buffer> read_ahead_buffers = new LinkedList<Buffer>();
-
- public TCFFileInputStream(IFileHandle handle) {
- this(handle, 0x1000);
- }
-
- public TCFFileInputStream(IFileHandle handle, int buf_size) {
- this.handle = handle;
- this.fs = handle.getService();
- this.buf_size = buf_size;
- }
-
- private void startReadAhead(Buffer prv) {
- if (suspend_read_ahead) return;
- if (read_ahead_buffers.size() > 0) {
- prv = read_ahead_buffers.getLast();
- }
- if (prv.eof) return;
- long pos = prv.offset + (prv.buf == null ? buf_size : prv.buf.length);
- while (read_ahead_buffers.size() < MAX_READ_AHEAD) {
- final Buffer buf = new Buffer(pos);
- buf.token = fs.read(handle, pos, buf_size, new IFileSystem.DoneRead() {
- public void doneRead(IToken token, FileSystemException error,
- byte[] data, boolean eof) {
- assert buf.token == token;
- assert read_ahead_buffers.contains(buf);
- buf.token = null;
- if (error != null) {
- suspend_read_ahead = true;
- read_ahead_buffers.remove(buf);
- }
- else if (data.length != buf_size) {
- buf.buf = data;
- buf.eof = eof;
- if (!eof) suspend_read_ahead = true;
- }
- else {
- buf.buf = data;
- buf.eof = eof;
- startReadAhead(buf);
- }
- if (waiting_client != null) {
- Protocol.invokeLater(waiting_client);
- waiting_client = null;
- }
- }
- });
- read_ahead_buffers.add(buf);
- pos += buf_size;
- }
- }
-
- private boolean stopReadAhead(Runnable done) {
- suspend_read_ahead = true;
- for (Iterator<Buffer> i = read_ahead_buffers.iterator(); i.hasNext();) {
- Buffer buf = i.next();
- if (buf.token == null || buf.token.cancel()) i.remove();
- }
- if (read_ahead_buffers.size() > 0) {
- assert waiting_client == null;
- waiting_client = done;
- return false;
- }
- return true;
- }
-
- @Override
- public synchronized int read() throws IOException {
- if (closed) throw new IOException("Stream is closed");
- while (buf == null || buf.offset > offset || buf.offset + buf.buf.length <= offset) {
- if (buf != null && buf.eof) return -1;
- buf = new TCFTask<Buffer>() {
- public void run() {
- assert waiting_client == null;
- while (read_ahead_buffers.size() > 0) {
- Buffer buf = read_ahead_buffers.getFirst();
- if (buf.offset == offset) {
- if (buf.token != null) {
- waiting_client = this;
- }
- else {
- startReadAhead(buf);
- read_ahead_buffers.remove(buf);
- done(buf);
- }
- return;
- }
- suspend_read_ahead = true;
- if (buf.token != null && buf.token.cancel()) buf.token = null;
- if (buf.token != null) {
- waiting_client = this;
- return;
- }
- read_ahead_buffers.remove(buf);
- }
- fs.read(handle, offset, buf_size, new IFileSystem.DoneRead() {
- public void doneRead(IToken token, FileSystemException error,
- byte[] data, boolean eof) {
- if (error != null) {
- error(error);
- return;
- }
- assert data != null && data.length <= buf_size;
- Buffer buf = new Buffer(offset);
- buf.buf = data;
- buf.eof = eof;
- if (!eof) {
- suspend_read_ahead = false;
- startReadAhead(buf);
- }
- done(buf);
- }
- });
- }
- }.getIO();
- assert buf.token == null;
- }
- int ofs = (int)(offset++ - buf.offset);
- return buf.buf[ofs] & 0xff;
- }
-
- @Override
- public synchronized int read(final byte arr[], final int off, final int len) throws IOException {
- if (closed) throw new IOException("Stream is closed");
- if (arr == null) throw new NullPointerException();
- if (off < 0 || len < 0 || len > arr.length - off) throw new IndexOutOfBoundsException();
- int pos = 0;
- while (pos < len) {
- if (buf != null && buf.offset <= offset && buf.offset + buf.buf.length > offset) {
- int buf_pos = (int)(offset - buf.offset);
- int buf_len = buf.buf.length - buf_pos;
- int n = len - pos < buf_len ? len - pos : buf_len;
- System.arraycopy(buf.buf, buf_pos, arr, off + pos, n);
- pos += n;
- offset += n;
- }
- else {
- int c = read();
- if (c == -1) {
- if (pos == 0) return -1;
- break;
- }
- arr[off + pos++] = (byte)c;
- }
- }
- return pos;
- }
-
- @Override
- public boolean markSupported() {
- return true;
- }
-
- @Override
- public synchronized void reset() throws IOException {
- if (closed) throw new IOException("Stream is closed");
- offset = mark;
- if (buf != null && buf.offset <= offset && buf.offset + buf.buf.length > offset) return;
- new TCFTask<Object>() {
- public void run() {
- if (!stopReadAhead(this)) return;
- done(this);
- }
- }.getIO();
- buf = null;
- }
-
- @Override
- public synchronized void mark(int readlimit) {
- mark = offset;
- }
-
- @Override
- public synchronized void close() throws IOException {
- if (closed) return;
- new TCFTask<Object>() {
- public void run() {
- if (!stopReadAhead(this)) return;
- assert read_ahead_buffers.isEmpty();
- fs.close(handle, new IFileSystem.DoneClose() {
- public void doneClose(IToken token, FileSystemException error) {
- if (error != null) error(error);
- else done(this);
- }
- });
- }
- }.getIO();
- closed = true;
- buf = null;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFFileOutputStream.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFFileOutputStream.java
deleted file mode 100644
index 33dadd7c7..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFFileOutputStream.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.util;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.io.OutputStream;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.tm.tcf.protocol.IToken;
-import org.eclipse.tm.tcf.services.IFileSystem;
-import org.eclipse.tm.tcf.services.IFileSystem.FileSystemException;
-import org.eclipse.tm.tcf.services.IFileSystem.IFileHandle;
-
-/**
- * TCFFileOutputStream is high performance OutputStream implementation over TCF FileSystem service.
- * The class uses write-back buffers to achieve maximum throughput.
- *
- * @noextend This class is not intended to be subclassed by clients.
- */
-public final class TCFFileOutputStream extends OutputStream {
-
- private static final int MAX_WRITE_BACK = 8;
-
- private final IFileHandle handle;
- private final IFileSystem fs;
- private final int buf_size;
- private final Set<IToken> write_commands = new HashSet<IToken>();
- private final int[] dirty = new int[1];
- private final byte[] buf;
- private int buf_pos = 0;
- private long offset = 0;
- private IOException flush_error;
- private boolean closed;
-
- public TCFFileOutputStream(IFileHandle handle) {
- this(handle, 0x1000);
- }
-
- public TCFFileOutputStream(IFileHandle handle, int buf_size) {
- this.handle = handle;
- this.fs = handle.getService();
- this.buf_size = buf_size;
- buf = new byte[buf_size];
- }
-
- @Override
- public synchronized void write(int b) throws IOException {
- if (closed) throw new IOException("Stream is closed");
- if (buf_pos == buf_size) flush();
- buf[buf_pos++] = (byte)b;
- }
-
- @Override
- public void write(byte b[], int off, int len) throws IOException {
- if (len == 0) return;
- if (b == null) throw new NullPointerException();
- if (off < 0 || off > b.length || len < 0 ||
- off + len > b.length || off + len < 0)
- throw new IndexOutOfBoundsException();
- while (len > 0) {
- if (buf_pos == buf_size) flush();
- if (buf_pos == 0 && len > buf_size) {
- flush(b, off, len);
- return;
- }
- int n = buf_size - buf_pos;
- if (len < n) n = len;
- System.arraycopy(b, off, buf, buf_pos, n);
- off += n;
- len -= n;
- buf_pos += n;
- }
- }
-
- @Override
- public synchronized void flush() throws IOException {
- if (buf_pos == 0) return;
- flush(buf, 0, buf_pos);
- buf_pos = 0;
- }
-
- private void flush(final byte[] buf, final int off, final int len) throws IOException {
- synchronized (dirty) {
- if (flush_error != null) throw flush_error;
- while (dirty[0] >= MAX_WRITE_BACK) {
- try {
- dirty.wait();
- }
- catch (InterruptedException e) {
- throw new InterruptedIOException();
- }
- }
- }
- new TCFTask<Object>() {
- public void run() {
- write_commands.add(fs.write(handle, offset, buf, off, len, new IFileSystem.DoneWrite() {
- public void doneWrite(IToken token, FileSystemException error) {
- assert write_commands.contains(token);
- write_commands.remove(token);
- if (error != null) {
- for (Iterator<IToken> i = write_commands.iterator(); i.hasNext();) {
- if (i.next().cancel()) i.remove();
- }
- }
- synchronized (dirty) {
- if (error != null && flush_error == null) flush_error = error;
- dirty[0] = write_commands.size();
- dirty.notifyAll();
- }
- }
- }));
- synchronized (dirty) {
- dirty[0] = write_commands.size();
- }
- done(this);
- }
- }.getIO();
- offset += len;
- }
-
- @Override
- public synchronized void close() throws IOException {
- if (closed) return;
- flush();
- synchronized (dirty) {
- while (dirty[0] > 0) {
- try {
- dirty.wait();
- }
- catch (InterruptedException e) {
- throw new InterruptedIOException();
- }
- }
- }
- new TCFTask<Object>() {
- public void run() {
- fs.close(handle, new IFileSystem.DoneClose() {
- public void doneClose(IToken token, FileSystemException error) {
- if (error != null) error(error);
- else done(this);
- }
- });
- }
- }.getIO();
- closed = true;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFTask.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFTask.java
deleted file mode 100644
index db0386f39..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/util/TCFTask.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.tm.tcf.util;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.Protocol;
-
-/**
- * A <tt>TCFTask</tt> is an utility class that represents the result of an asynchronous
- * communication over TCF framework. Methods are provided to check if the communication is
- * complete, to wait for its completion, and to retrieve the result of
- * the communication.
- *
- * TCFTask is useful when communication is requested by a thread other then TCF dispatch thread.
- * If client has a global state, for example, cached remote data, multithreading should be avoided,
- * because it is extremely difficult to ensure absence of racing conditions or deadlocks in such environment.
- * Such clients should consider message driven design, see TCFDataCache and its usage as an example.
- *
- * If a client is extending TCFTask it should implement run() method to perform actual communications.
- * The run() method will be execute by TCF dispatch thread, and client code should then call either done() or
- * error() to indicate that task computations are complete.
- */
-public abstract class TCFTask<V> implements Runnable, Future<V> {
-
- private V result;
- private boolean done;
- private Throwable error;
- private boolean canceled;
- private IChannel channel;
- private IChannel.IChannelListener channel_listener;
-
- /**
- * Construct a TCF task object and schedule it for execution.
- */
- public TCFTask() {
- Protocol.invokeLater(new Runnable() {
- public void run() {
- try {
- TCFTask.this.run();
- }
- catch (Throwable x) {
- if (!done && error == null) error(x);
- }
- }
- });
- }
-
- /**
- * Construct a TCF task object and schedule it for execution.
- * The task will be canceled if it is not completed after given timeout.
- * @param timeout - max time in milliseconds.
- */
- public TCFTask(long timeout) {
- Protocol.invokeLater(new Runnable() {
- public void run() {
- try {
- TCFTask.this.run();
- }
- catch (Throwable x) {
- if (!done && error == null) error(x);
- }
- }
- });
- Protocol.invokeLater(timeout, new Runnable() {
- public void run() {
- cancel(true);
- }
- });
- }
-
- /**
- * Construct a TCF task object and schedule it for execution.
- * The task will be canceled if the given channel is closed or
- * terminated while the task is in progress.
- * @param channel
- */
- public TCFTask(final IChannel channel) {
- Protocol.invokeLater(new Runnable() {
- public void run() {
- try {
- if (channel.getState() != IChannel.STATE_OPEN) throw new Exception("Channel is closed");
- TCFTask.this.channel = channel;
- channel_listener = new IChannel.IChannelListener() {
-
- public void congestionLevel(int level) {
- }
-
- public void onChannelClosed(final Throwable error) {
- cancel(true);
- }
-
- public void onChannelOpened() {
- }
- };
- channel.addChannelListener(channel_listener);
- TCFTask.this.run();
- }
- catch (Throwable x) {
- if (!done && error == null) error(x);
- }
- }
- });
- }
-
- /**
- * Set a result of this task and notify all threads waiting for the task to complete.
- * The method is supposed to be called in response to executing of run() method of this task.
- *
- * @param result - the computed result
- */
- public synchronized void done(V result) {
- assert Protocol.isDispatchThread();
- if (canceled) return;
- assert !done;
- assert this.error == null;
- assert this.result == null;
- this.result = result;
- done = true;
- if (channel != null) channel.removeChannelListener(channel_listener);
- notifyAll();
- }
-
- /**
- * Set a error and notify all threads waiting for the task to complete.
- * The method is supposed to be called in response to executing of run() method of this task.
- *
- * @param error - computation error.
- */
- public synchronized void error(Throwable error) {
- assert Protocol.isDispatchThread();
- assert error != null;
- if (canceled) return;
- assert this.error == null;
- assert this.result == null;
- assert !done;
- this.error = error;
- if (channel != null) channel.removeChannelListener(channel_listener);
- notifyAll();
- }
-
- /**
- * Attempts to cancel execution of this task. This attempt will
- * fail if the task has already completed, already been canceled,
- * or could not be canceled for some other reason. If successful,
- * and this task has not started when <tt>cancel</tt> is called,
- * this task should never run. If the task has already started,
- * then the <tt>mayInterruptIfRunning</tt> parameter determines
- * whether the thread executing this task should be interrupted in
- * an attempt to stop the task.
- *
- * @param mayInterruptIfRunning <tt>true</tt> if the thread executing this
- * task should be interrupted; otherwise, in-progress tasks are allowed
- * to complete
- * @return <tt>false</tt> if the task could not be canceled,
- * typically because it has already completed normally;
- * <tt>true</tt> otherwise
- */
- public synchronized boolean cancel(boolean mayInterruptIfRunning) {
- assert Protocol.isDispatchThread();
- if (isDone()) return false;
- canceled = true;
- error = new CancellationException();
- if (channel != null) channel.removeChannelListener(channel_listener);
- notifyAll();
- return true;
- }
-
- /**
- * Waits if necessary for the computation to complete, and then
- * retrieves its result.
- *
- * @return the computed result
- * @throws CancellationException if the computation was canceled
- * @throws ExecutionException if the computation threw an
- * exception
- * @throws InterruptedException if the current thread was interrupted
- * while waiting
- */
- public synchronized V get() throws InterruptedException, ExecutionException {
- assert !Protocol.isDispatchThread();
- while (!isDone()) wait();
- if (error != null) {
- if (error instanceof ExecutionException) throw (ExecutionException)error;
- if (error instanceof InterruptedException) throw (InterruptedException)error;
- throw new ExecutionException("TCF task aborted", error);
- }
- return result;
- }
-
- /**
- * Waits if necessary for the computation to complete, and then
- * retrieves its result.
- *
- * @return the computed result
- * @throws Error if the computation was canceled or threw an exception
- */
- public synchronized V getE() {
- assert !Protocol.isDispatchThread();
- while (!isDone()) {
- try {
- wait();
- }
- catch (InterruptedException x) {
- throw new Error(x);
- }
- }
- if (error != null) {
- if (error instanceof Error) throw (Error)error;
- throw new Error("TCF task aborted", error);
- }
- return result;
- }
-
- /**
- * Waits if necessary for the computation to complete, and then
- * retrieves its result.
- *
- * @return the computed result
- * @throws IOException if the computation was canceled or threw an exception
- */
- public synchronized V getIO() throws IOException {
- assert !Protocol.isDispatchThread();
- while (!isDone()) {
- try {
- wait();
- }
- catch (InterruptedException x) {
- throw new InterruptedIOException();
- }
- }
- if (error != null) {
- if (error instanceof IOException) throw (IOException)error;
- IOException y = new IOException("TCF task aborted");
- y.initCause(error);
- throw y;
- }
- return result;
- }
-
- /**
- * Waits if necessary for at most the given time for the computation
- * to complete, and then retrieves its result, if available.
- *
- * @param timeout the maximum time to wait
- * @param unit the time unit of the timeout argument
- * @return the computed result
- * @throws CancellationException if the computation was canceled
- * @throws ExecutionException if the computation threw an exception
- * @throws InterruptedException if the current thread was interrupted
- * while waiting
- * @throws TimeoutException if the wait timed out
- */
- public synchronized V get(long timeout, TimeUnit unit)
- throws InterruptedException, ExecutionException, TimeoutException {
- assert !Protocol.isDispatchThread();
- if (!isDone()) {
- wait(unit.toMillis(timeout));
- if (!isDone()) throw new TimeoutException();
- }
- if (error != null) {
- if (error instanceof InterruptedException) throw (InterruptedException)error;
- if (error instanceof ExecutionException) throw (ExecutionException)error;
- if (error instanceof TimeoutException) throw (TimeoutException)error;
- throw new ExecutionException("TCF task aborted", error);
- }
- return result;
- }
-
- /**
- * Returns <tt>true</tt> if this task was canceled before it completed
- * normally.
- *
- * @return <tt>true</tt> if task was canceled before it completed
- */
- public synchronized boolean isCancelled() {
- return canceled;
- }
-
- /**
- * Returns <tt>true</tt> if this task completed.
- *
- * Completion may be due to normal termination, an exception, or
- * cancellation -- in all of these cases, this method will return
- * <tt>true</tt>.
- *
- * @return <tt>true</tt> if this task completed.
- */
- public synchronized boolean isDone() {
- return error != null || done;
- }
-
- /**
- * Return task execution error if any.
- * @return Throwable object or null
- */
- protected Throwable getError() {
- return error;
- }
-
- /**
- * Return task execution result if any.
- * @return result object
- */
- protected V getResult() {
- return result;
- }
-}

Back to the top