Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractCMTest.java16
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/AbstractCacheManager.java7
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/BreakpointsCM.java13
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/DiagnosticsCM.java9
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/LineNumbersCM.java6
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ProcessesCM.java6
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RegistersCM.java8
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RunControlCM.java12
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/StackTraceCM.java8
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/SymbolsCM.java11
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/util/ChannelQuery.java60
-rw-r--r--tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/util/TokenCache.java44
12 files changed, 176 insertions, 24 deletions
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractCMTest.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractCMTest.java
index 57417d694..6370f7c03 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractCMTest.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/AbstractCMTest.java
@@ -219,14 +219,14 @@ public abstract class AbstractCMTest extends TcfTestCase implements IViewerUpdat
}
protected void setUpServiceListeners() throws Exception{
- fRunControlCM = new RunControlCM(rc);
- fDiagnosticsCM = new DiagnosticsCM(diag);
- fBreakpointsCM = new BreakpointsCM(bp);
- fStackTraceCM = new StackTraceCM(stk, fRunControlCM, fMemory, fMemoryMap);
- fSymbolsCM = new SymbolsCM(syms, fRunControlCM, fMemoryMap);
- fLineNumbersCM = new LineNumbersCM(fLineNumbers, fMemoryMap, fRunControlCM);
- fRegistersCM = new RegistersCM(fRegisters, rc);
- fProcessesCM = new ProcessesCM(fProcesses);
+ fRunControlCM = new RunControlCM(channels[0], rc);
+ fDiagnosticsCM = new DiagnosticsCM(channels[0], diag);
+ fBreakpointsCM = new BreakpointsCM(channels[0], bp);
+ fStackTraceCM = new StackTraceCM(channels[0], stk, fRunControlCM, fMemory, fMemoryMap);
+ fSymbolsCM = new SymbolsCM(channels[0], syms, fRunControlCM, fMemoryMap);
+ fLineNumbersCM = new LineNumbersCM(channels[0], fLineNumbers, fMemoryMap, fRunControlCM);
+ fRegistersCM = new RegistersCM(channels[0], fRegisters, rc);
+ fProcessesCM = new ProcessesCM(channels[0], fProcesses);
}
protected void tearDownServiceListeners() throws Exception{
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/AbstractCacheManager.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/AbstractCacheManager.java
index 973097f9f..efca45909 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/AbstractCacheManager.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/AbstractCacheManager.java
@@ -12,12 +12,15 @@ package org.eclipse.tcf.debug.test.services;
import java.util.LinkedHashMap;
import java.util.Map;
+import org.eclipse.tcf.protocol.IChannel;
+
public class AbstractCacheManager {
protected Map<Key<?>, Object> fMap = new LinkedHashMap<Key<?>, Object>();
+ protected final IChannel fChannel;
- public AbstractCacheManager() {
- super();
+ public AbstractCacheManager(IChannel channel) {
+ fChannel = channel;
}
public void dispose() {
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/BreakpointsCM.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/BreakpointsCM.java
index 9116e48c8..a0ac65371 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/BreakpointsCM.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/BreakpointsCM.java
@@ -14,6 +14,7 @@ import java.util.Map;
import org.eclipse.tcf.debug.test.util.ICache;
import org.eclipse.tcf.debug.test.util.TokenCache;
+import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.services.IBreakpoints;
@@ -24,7 +25,8 @@ public class BreakpointsCM extends AbstractCacheManager implements IBreakpoints.
private IBreakpoints fService;
- public BreakpointsCM(IBreakpoints service) {
+ public BreakpointsCM(IChannel channel, IBreakpoints service) {
+ super (channel);
fService = service;
fService.addListener(this);
}
@@ -36,7 +38,8 @@ public class BreakpointsCM extends AbstractCacheManager implements IBreakpoints.
super.dispose();
}
- private abstract static class DoneCommandCache extends TokenCache<Object> implements IBreakpoints.DoneCommand {
+ private abstract class DoneCommandCache extends TokenCache<Object> implements IBreakpoints.DoneCommand {
+ DoneCommandCache() { super(fChannel); }
public void doneCommand(IToken token, Exception error) {
set(token, null, error);
}
@@ -115,6 +118,7 @@ public class BreakpointsCM extends AbstractCacheManager implements IBreakpoints.
}
private class IDsCache extends TokenCache<String[]> implements IBreakpoints.DoneGetIDs {
+ IDsCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.getIDs(this);
@@ -146,6 +150,7 @@ public class BreakpointsCM extends AbstractCacheManager implements IBreakpoints.
String fId;
public PropertiesCache(String id) {
+ super(fChannel);
fId = id;
}
@@ -183,6 +188,7 @@ public class BreakpointsCM extends AbstractCacheManager implements IBreakpoints.
String fId;
public StatusCache(String id) {
+ super(fChannel);
fId = id;
}
@@ -212,7 +218,8 @@ public class BreakpointsCM extends AbstractCacheManager implements IBreakpoints.
}
public ICache<Map<String,Object>> getCapabilities(final String id) {
- class MyCache extends TokenCache<Map<String,Object>> implements IBreakpoints.DoneGetCapabilities {
+ class MyCache extends TokenCache<Map<String,Object>> implements IBreakpoints.DoneGetCapabilities {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.getCapabilities(id, this);
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/DiagnosticsCM.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/DiagnosticsCM.java
index c5636bd0e..c1b679bd9 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/DiagnosticsCM.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/DiagnosticsCM.java
@@ -12,6 +12,7 @@ package org.eclipse.tcf.debug.test.services;
import org.eclipse.tcf.debug.test.util.ICache;
import org.eclipse.tcf.debug.test.util.TokenCache;
+import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.services.IDiagnostics;
import org.eclipse.tcf.services.IDiagnostics.ISymbol;
@@ -22,7 +23,8 @@ import org.eclipse.tcf.services.IDiagnostics.ISymbol;
public class DiagnosticsCM extends AbstractCacheManager{
private IDiagnostics fService;
- public DiagnosticsCM(IDiagnostics service) {
+ public DiagnosticsCM(IChannel channel, IDiagnostics service) {
+ super(channel);
fService = service;
}
@@ -33,6 +35,7 @@ public class DiagnosticsCM extends AbstractCacheManager{
public ICache<String> echo(final String msg, Object clientId) {
class MyCache extends TokenCache<String> implements IDiagnostics.DoneEcho {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.echo(msg, this);
@@ -49,6 +52,7 @@ public class DiagnosticsCM extends AbstractCacheManager{
public ICache<String[]> getTestList() {
class MyCache extends TokenCache<String[]> implements IDiagnostics.DoneGetTestList {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.getTestList(this);
@@ -65,6 +69,7 @@ public class DiagnosticsCM extends AbstractCacheManager{
public ICache<String> runTest(final String name, Object clientId) {
class MyCache extends TokenCache<String> implements IDiagnostics.DoneRunTest {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.runTest(name, this);
@@ -81,6 +86,7 @@ public class DiagnosticsCM extends AbstractCacheManager{
public ICache<Object> cancelTest(final String context_id, Object clientId) {
class MyCache extends TokenCache<Object> implements IDiagnostics.DoneCancelTest {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.cancelTest(context_id, this);
@@ -119,6 +125,7 @@ public class DiagnosticsCM extends AbstractCacheManager{
public ICache<IDiagnostics.ISymbol> getSymbol(final String context_id, final String symbol_name) {
class MyCache extends TokenCache<IDiagnostics.ISymbol> implements IDiagnostics.DoneGetSymbol {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.getSymbol(context_id, symbol_name, this);
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/LineNumbersCM.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/LineNumbersCM.java
index 89c1a3f8f..0e60793a6 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/LineNumbersCM.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/LineNumbersCM.java
@@ -16,6 +16,7 @@ import java.util.concurrent.ExecutionException;
import org.eclipse.tcf.debug.test.util.ICache;
import org.eclipse.tcf.debug.test.util.TokenCache;
import org.eclipse.tcf.debug.test.util.TransactionCache;
+import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.services.ILineNumbers;
import org.eclipse.tcf.services.ILineNumbers.CodeArea;
@@ -34,7 +35,8 @@ public class LineNumbersCM extends AbstractCacheManager {
private IMemoryMap fMemoryMap;
private RunControlCM fRunControlCM;
- public LineNumbersCM(ILineNumbers lineNumbers, IMemoryMap memMap, RunControlCM runControlCM) {
+ public LineNumbersCM(IChannel channel, ILineNumbers lineNumbers, IMemoryMap memMap, RunControlCM runControlCM) {
+ super(channel);
fService = lineNumbers;
fMemoryMap = memMap;
fMemoryMap.addListener(fMemoryMapListener);
@@ -95,6 +97,7 @@ public class LineNumbersCM extends AbstractCacheManager {
private ICache<CodeArea[]> doMapToSource(final String mem_id, final Number start_address, final Number end_address) {
class MyCache extends TokenCache<CodeArea[]> implements ILineNumbers.DoneMapToSource {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.mapToSource(mem_id, start_address, end_address, this);
@@ -159,6 +162,7 @@ public class LineNumbersCM extends AbstractCacheManager {
private ICache<CodeArea[]> doMapToMemory(final String mem_id, final String file, final int line, final int column) {
class MyCache extends TokenCache<CodeArea[]> implements ILineNumbers.DoneMapToMemory {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.mapToMemory(mem_id, file, line, column, this);
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ProcessesCM.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ProcessesCM.java
index ff2db1ff6..60b11a5b7 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ProcessesCM.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/ProcessesCM.java
@@ -12,6 +12,7 @@ package org.eclipse.tcf.debug.test.services;
import org.eclipse.tcf.debug.test.util.ICache;
import org.eclipse.tcf.debug.test.util.TokenCache;
+import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.services.IProcesses;
import org.eclipse.tcf.services.IProcesses.ProcessContext;
@@ -24,7 +25,8 @@ public class ProcessesCM extends AbstractCacheManager implements IProcesses.Proc
private IProcesses fService;
private final ResetMap fResetMap = new ResetMap();
- public ProcessesCM(IProcesses service) {
+ public ProcessesCM(IChannel channel, IProcesses service) {
+ super(channel);
fService = service;
fService.addListener(this);
}
@@ -37,6 +39,7 @@ public class ProcessesCM extends AbstractCacheManager implements IProcesses.Proc
public ICache<String[]> getChildren(final String id, final boolean attached_only) {
class MyCache extends TokenCache<String[]> implements IProcesses.DoneGetChildren {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.getChildren(id, attached_only, this);
@@ -74,6 +77,7 @@ public class ProcessesCM extends AbstractCacheManager implements IProcesses.Proc
public ICache<ProcessContext> getContext(final String id) {
class MyCache extends TokenCache<ProcessContext> implements IProcesses.DoneGetContext {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.getContext(id, this);
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RegistersCM.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RegistersCM.java
index 319adb272..2d5406d5c 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RegistersCM.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RegistersCM.java
@@ -14,6 +14,7 @@ import java.util.Map;
import org.eclipse.tcf.debug.test.util.ICache;
import org.eclipse.tcf.debug.test.util.TokenCache;
+import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.services.IRegisters;
import org.eclipse.tcf.services.IRegisters.RegistersContext;
@@ -29,7 +30,8 @@ public class RegistersCM extends AbstractCacheManager implements IRunControl.Run
private final ResetMap fRunControlStateResetMap = new ResetMap();
private final ResetMap fRegistersMap = new ResetMap();
- public RegistersCM(IRegisters service, IRunControl runControl) {
+ public RegistersCM(IChannel channel, IRegisters service, IRunControl runControl) {
+ super(channel);
fService = service;
fRunControl = runControl;
fRunControl.addListener(this);
@@ -43,6 +45,7 @@ public class RegistersCM extends AbstractCacheManager implements IRunControl.Run
public ICache<String[]> getChildren(final String id) {
class MyCache extends TokenCache<String[]> implements IRegisters.DoneGetChildren {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.getChildren(id, this);
@@ -61,6 +64,7 @@ public class RegistersCM extends AbstractCacheManager implements IRunControl.Run
public ICache<RegistersContext> getContext(final String id) {
class MyCache extends TokenCache<RegistersContext> implements IRegisters.DoneGetContext {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return fService.getContext(id, this);
@@ -79,6 +83,7 @@ public class RegistersCM extends AbstractCacheManager implements IRunControl.Run
public ICache<byte[]> getContextValue(final RegistersContext context) {
class MyCache extends TokenCache<byte[]> implements IRegisters.DoneGet {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return context.get(this);
@@ -120,6 +125,7 @@ public class RegistersCM extends AbstractCacheManager implements IRunControl.Run
public ICache<Object> setContextValue(final RegistersContext context, Object clientKey, final byte[] value) {
class MyCache extends TokenCache<Object> implements IRegisters.DoneSet {
+ MyCache() { super(fChannel); }
@Override
protected IToken retrieveToken() {
return context.set(value, this);
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RunControlCM.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RunControlCM.java
index db8546769..2d0688eb4 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RunControlCM.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/RunControlCM.java
@@ -23,6 +23,7 @@ import org.eclipse.tcf.debug.test.util.DataCallback;
import org.eclipse.tcf.debug.test.util.ICache;
import org.eclipse.tcf.debug.test.util.TokenCache;
import org.eclipse.tcf.debug.test.util.Transaction;
+import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.services.IRunControl;
import org.eclipse.tcf.services.IRunControl.DoneCommand;
@@ -39,7 +40,8 @@ public class RunControlCM extends AbstractCacheManager implements RunControlList
private final ResetMap fChildrenResetMap = new ResetMap();
private final List<RunControlListener> fListeners = new ArrayList<RunControlListener>();
- public RunControlCM(IRunControl service) {
+ public RunControlCM(IChannel channel, IRunControl service) {
+ super(channel);
fService = service;
fService.addListener(this);
}
@@ -83,6 +85,8 @@ public class RunControlCM extends AbstractCacheManager implements RunControlList
}
private abstract class RunControlTokenCache<V> extends TokenCache<V> {
+ RunControlTokenCache() { super(fChannel); }
+
abstract protected String getId();
protected void set(IToken token, V data, Throwable error) {
@@ -94,6 +98,7 @@ public class RunControlCM extends AbstractCacheManager implements RunControlList
private class ChildrenCache extends TokenCache<String[]> implements IRunControl.DoneGetChildren {
private final String fId;
public ChildrenCache(String id) {
+ super(fChannel);
fId = id;
}
@@ -138,6 +143,7 @@ public class RunControlCM extends AbstractCacheManager implements RunControlList
private final RunControlContext fContext;
public InnerContextStateCache(RunControlContext context) {
+ super(fChannel);
fContext = context;
}
@@ -230,7 +236,9 @@ public class RunControlCM extends AbstractCacheManager implements RunControlList
}
}
- private abstract static class DoneCommandCache extends TokenCache<Object> implements DoneCommand {
+ private abstract class DoneCommandCache extends TokenCache<Object> implements DoneCommand {
+ DoneCommandCache() { super(fChannel); }
+
public void doneCommand(IToken token, Exception error) {
set(token, null, error);
}
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/StackTraceCM.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/StackTraceCM.java
index f6cb8f283..c9eb85b5e 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/StackTraceCM.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/StackTraceCM.java
@@ -23,6 +23,7 @@ import org.eclipse.tcf.debug.test.util.RangeCache;
import org.eclipse.tcf.debug.test.util.TokenCache;
import org.eclipse.tcf.debug.test.util.Transaction;
import org.eclipse.tcf.debug.test.util.TransactionCache;
+import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.services.IMemory;
import org.eclipse.tcf.services.IMemory.MemoryContext;
@@ -120,7 +121,8 @@ public class StackTraceCM extends AbstractCacheManager {
}
};
- public StackTraceCM(IStackTrace service, RunControlCM runControlCM, IMemory memory, IMemoryMap memoryMap) {
+ public StackTraceCM(IChannel channel, IStackTrace service, RunControlCM runControlCM, IMemory memory, IMemoryMap memoryMap) {
+ super(channel);
fService = service;
fRunControlCM = runControlCM;
fRunControlCM.getService().addListener(fRunControlListener);
@@ -142,6 +144,8 @@ public class StackTraceCM extends AbstractCacheManager {
class MyCache extends TransactionCache<String[]> {
class InnerCache extends TokenCache<String[]> implements IStackTrace.DoneGetChildren {
+ InnerCache() { super(fChannel); }
+
@Override
protected IToken retrieveToken() {
return fService.getChildren(id, this);
@@ -214,6 +218,8 @@ public class StackTraceCM extends AbstractCacheManager {
class MyCache extends TransactionCache<StackTraceContext[]> {
class InnerCache extends TokenCache<StackTraceContext[]> implements IStackTrace.DoneGetContext {
+ InnerCache() { super(fChannel); }
+
@Override
protected IToken retrieveToken() {
return fService.getContext(ids, this);
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/SymbolsCM.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/SymbolsCM.java
index 13658b652..0716d52cf 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/SymbolsCM.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/services/SymbolsCM.java
@@ -18,6 +18,7 @@ import org.eclipse.tcf.debug.test.util.AbstractCache;
import org.eclipse.tcf.debug.test.util.ICache;
import org.eclipse.tcf.debug.test.util.TokenCache;
import org.eclipse.tcf.debug.test.util.TransactionCache;
+import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
import org.eclipse.tcf.services.IMemoryMap;
import org.eclipse.tcf.services.IMemoryMap.MemoryMapListener;
@@ -38,7 +39,8 @@ public class SymbolsCM extends AbstractCacheManager {
private IMemoryMap fMemoryMap;
private RunControlCM fRunControlCM;
- public SymbolsCM(ISymbols service, RunControlCM runControl, IMemoryMap memoryMap) {
+ public SymbolsCM(IChannel channel, ISymbols service, RunControlCM runControl, IMemoryMap memoryMap) {
+ super(channel);
fService = service;
fRunControlCM = runControl;
fRunControlCM.addListener(fRunControlListener);
@@ -103,6 +105,7 @@ public class SymbolsCM extends AbstractCacheManager {
private class InnerChildrenCache extends TokenCache<String[]> implements ISymbols.DoneGetChildren {
private final String fId;
public InnerChildrenCache(String id) {
+ super(fChannel);
fId = id;
}
@@ -131,6 +134,8 @@ public class SymbolsCM extends AbstractCacheManager {
class MyCache extends TransactionCache<Symbol> {
class InnerCache extends TokenCache<Symbol> implements ISymbols.DoneGetContext{
+ InnerCache() { super(fChannel); }
+
@Override
protected IToken retrieveToken() {
return fService.getContext(id, this);
@@ -162,6 +167,8 @@ public class SymbolsCM extends AbstractCacheManager {
public ICache<Map<String, Object>> getLocationInfo(final String symbol_id) {
class InnerCache extends TokenCache<Map<String,Object>> implements ISymbols.DoneGetLocationInfo {
+ InnerCache() { super(fChannel); }
+
@Override
protected IToken retrieveToken() {
return fService.getLocationInfo(symbol_id, this);
@@ -216,6 +223,7 @@ public class SymbolsCM extends AbstractCacheManager {
private final String fName;
public InnerFindCache(String id, Number ip, String name) {
+ super(fChannel);
fId = id;
fIp = ip;
fName = name;
@@ -276,6 +284,7 @@ public class SymbolsCM extends AbstractCacheManager {
private final Number fAddr;
public InnerFindByAddrCache(String id, Number addr) {
+ super(fChannel);
fId = id;
fAddr = addr;
}
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/util/ChannelQuery.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/util/ChannelQuery.java
new file mode 100644
index 000000000..5ee352b34
--- /dev/null
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/util/ChannelQuery.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.debug.test.util;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.eclipse.tcf.protocol.IChannel;
+
+/**
+ * Query extension which automatically completes when a TCF channel is closed.
+ */
+abstract public class ChannelQuery<V> extends Query<V> {
+
+ private final IChannel fChannel;
+
+ public ChannelQuery(IChannel channel) {
+ fChannel = channel;
+ }
+
+ @Override
+ final protected void execute(final DataCallback<V> callback) {
+ final AtomicBoolean done = new AtomicBoolean(false);
+ final IChannel.IChannelListener channelListener = new IChannel.IChannelListener() {
+ @Override
+ public void onChannelClosed(Throwable error) {
+ if (!done.getAndSet(true)) {
+ fChannel.removeChannelListener(this);
+ callback.done(new IOException("Channel closed.", error));
+ }
+ }
+ @Override
+ public void congestionLevel(int level) {}
+ @Override
+ public void onChannelOpened() {}
+ };
+ fChannel.addChannelListener(channelListener);
+
+ channelExecute(new DataCallback<V>(callback) {
+ @Override
+ protected void handleCompleted() {
+ if (!done.getAndSet(true)) {
+ fChannel.removeChannelListener(channelListener);
+ callback.done(getData(), getError());
+ }
+ }
+ });
+
+ }
+
+ abstract protected void channelExecute(final DataCallback<V> callback);
+}
diff --git a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/util/TokenCache.java b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/util/TokenCache.java
index b05815666..d794edded 100644
--- a/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/util/TokenCache.java
+++ b/tests/plugins/org.eclipse.tcf.debug.test/src/org/eclipse/tcf/debug/test/util/TokenCache.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.tcf.debug.test.util;
+import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.tcf.debug.test.services.ResetMap.IResettable;
+import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IToken;
/**
@@ -20,15 +22,47 @@ import org.eclipse.tcf.protocol.IToken;
*/
public abstract class TokenCache<V> extends AbstractCache<V> implements IResettable {
+ private final IChannel fChannel;
private AtomicReference<IToken> fToken = new AtomicReference<IToken>();
+ private IChannel.IChannelListener fChannelListener = new IChannel.IChannelListener() {
+ @Override
+ public void onChannelClosed(Throwable error) {
+ if (!isValid()) {
+ set(null, new IOException("Channel closed.", error), true);
+ }
+ }
+ @Override
+ public void congestionLevel(int level) {}
+ @Override
+ public void onChannelOpened() {}
+ };
+
+ public TokenCache(IChannel channel) {
+ fChannel = channel;
+ }
+
+ private void addChannelListener() {
+ fChannel.addChannelListener(fChannelListener);
+ }
+
+ private void removeChannelListener() {
+ fChannel.removeChannelListener(fChannelListener);
+ }
@Override
final protected void retrieve() {
- fToken.set(retrieveToken());
+ IToken previous = fToken.getAndSet(retrieveToken());
+ if (previous == null) {
+ addChannelListener();
+ }
}
protected boolean checkToken(IToken token) {
- return fToken.compareAndSet(token, null);
+ boolean tokenMatches = fToken.compareAndSet(token, null);
+ if (tokenMatches) {
+ removeChannelListener();
+ }
+ return tokenMatches;
}
abstract protected IToken retrieveToken();
@@ -45,12 +79,16 @@ public abstract class TokenCache<V> extends AbstractCache<V> implements IResetta
// If new value was set to the cache but a command is still
// outstanding. Cancel the command.
IToken token = fToken.getAndSet(null);
- if (token != null) token.cancel();
+ if (token != null) {
+ token.cancel();
+ removeChannelListener();
+ }
}
@Override
protected void canceled() {
IToken token = fToken.getAndSet(null);
token.cancel();
+ removeChannelListener();
}
}

Back to the top