FileDocCategorySizeDatePackage
InvocStoreCancel.javaAPI DocphoneME MR2 API (J2ME)3535Wed May 02 18:00:44 BST 2007com.sun.midp.content

InvocStoreCancel

public class InvocStoreCancel extends Object implements Runnable
A test thread to test cancel and get interactions. The test strategy is to block for an Invocation and then see. Did the cancel unblock the request?

Fields Summary
public int
numTry
The number of gets attempted.
public int
numNotPending
The number of null results.
public int
numPending
The number of non-null results.
AppProxy
appl
The AppProxy to monitor.
private boolean
stopping
true to stop processing.
private boolean
type
True to block using get; false to block using select.
Constructors Summary
InvocStoreCancel(boolean type, AppProxy appl)
Construct a new context.

param
type true to blocking using get; false to use listen.

	this.type = type;
	this.appl = appl;
    
Methods Summary
private voidblockingGet()
Run the test for blocking get and cancel.

	while (!stopping) {
	    numTry++;
	    InvocationImpl get =
		InvocationStore.getResponse(new InvocationImpl(),
					    appl.getStorageId(), appl.getClassname(),
					    true);
	    if (get == null) {
		numNotPending++;
	    } else {
		numPending++;
	    }
	}
    
private voidblockingListen()
Run the test for blocking listen and cancel.

	while (!stopping) {
	    numTry++;
	    boolean pending = InvocationStore.listen(appl.getStorageId(),
						     appl.getClassname(),
						     false, true);
	    if (pending) {
		numPending++;
	    } else {
		numNotPending++;
	    }
	}
    
public intcheck()
Check the counters and return the level.

return
the number of transactions.

	if (numNotPending + numPending != numTry) {
	    throw new RuntimeException("inconsistent counters");
	}
	return numTry;
    
voidreset()
Reset the counters.

	numTry = 0;
	numNotPending = 0;
	numPending = 0;
    
public voidrun()
Loop getting Invocations in the standard form. Keep track of how many are received that non-null and null.

	if (type) {
	    blockingGet();
	} else {
	    blockingListen();
	}
    
voidstop()
Called to stop this thread.

	stopping = true;