Methods Summary |
---|
static void | cancel()Cancel a blocked {@link #get} or {@link #listen}
method if it is blocked in the native code.
cancelCount++;
cancel0();
|
private static native void | cancel0()Native method to unblock any threads that might be
waiting for an invocation by way of having called
{@link #get0}.
|
private static InvocationImpl | get(InvocationImpl invoc, int mode, boolean shouldBlock)Get an InvocationImpl from the store using a MIDlet suiteId
and classname.
The mode controls whether getting an Invocation
from the store removes it from the store.
String classname = invoc.classname;
invoc.setArgs(null);
invoc.setData(null);
int s = 0;
int oldCancelCount = cancelCount;
while ((s = get0(invoc, invoc.suiteId, invoc.classname,
mode, shouldBlock)) != 1) {
if (s == -1) {
/*
* Sizes of arguments and data buffers were insufficient
* reallocate and retry.
*/
invoc.setArgs(new String[invoc.argsLen]);
invoc.setData(new byte[invoc.dataLen]);
continue;
}
// Don't wait unless requested
if (!shouldBlock) {
break;
}
// No matching request; retry unless cancelled
if (cancelCount > oldCancelCount) {
// Was cancelled; s == 0 -> no Invocation
break;
}
}
// Update the return if no invocation
if (s == 0) {
invoc = null;
}
if (AppProxy.LOG_INFO) {
AppProxy.getCurrent().logInfo("Store get: " +
classname +
", mode: " + mode +
", " + invoc);
}
return invoc;
|
private static native int | get0(InvocationImpl invoc, int suiteId, java.lang.String classname, int mode, boolean shouldBlock)Native method to fill an available InvocationImpl with an
available stored Invocation with the status (if non-zero),
the suiteId, classname in the prototype InvocationImpl.
Any InvocationImpl with a matching status, suite and
class will be returned.
Depending on the mode the stored invocation will be removed
from the store.
|
static InvocationImpl | getByTid(int tid, int relative)Get an Invocation from the store based on its tid .
The normal state transitions and dispositions are NOT performed.
If TID == 0 then the first tid is used as the reference.
If TID == 0 and relative == 0 then null is returned.
This method never waits.
InvocationImpl invoc = new InvocationImpl();
int mode = MODE_TID;
if (tid != 0) {
if (relative < 0) {
mode = MODE_TID_PREV;
} else if (relative > 0) {
mode = MODE_TID_NEXT;
}
}
invoc.suiteId = MIDletSuite.UNUSED_SUITE_ID;
invoc.classname = null;
invoc.tid = tid;
return get(invoc, mode, false);
|
static InvocationImpl | getCleanup(int suiteId, java.lang.String classname)Performs cleanup for a ContentHandler
by suiteId and classname.
Any marked {@link #setCleanup} invocations still in the queue
are handled based on status:
- ACTIVE Invocations are returned from this method
so they can be have the ERROR status set and so the
invoking application relaunched.
- INIT Invocations are requeued to the invoking application
with ERROR status.
- OK, CANCELLED, ERROR, or INITIATED Invocations are
discrded.
- HOLD status Invocations are retained pending
completion of previous Invocation. TBD: Chained HOLDs...
InvocationImpl invoc = new InvocationImpl();
invoc.suiteId = suiteId;
invoc.classname = classname;
return get(invoc, MODE_CLEANUP, false);
|
static InvocationImpl | getRequest(int suiteId, java.lang.String classname, boolean shouldBlock)Get a new InvocationImpl request from the store using a MIDlet
suiteId and classname.
InvocationImpl invoc = new InvocationImpl();
if (suiteId == MIDletSuite.UNUSED_SUITE_ID || classname == null) {
throw new NullPointerException();
}
invoc.suiteId = suiteId;
invoc.classname = classname;
return get(invoc, MODE_REQUEST, shouldBlock);
|
static InvocationImpl | getResponse(InvocationImpl invoc, int suiteId, java.lang.String classname, boolean shouldBlock)Get a new InvocationImpl response from the store using a
MIDlet suiteId and classname.
The response is removed from the store.
invoc.suiteId = suiteId;
invoc.classname = classname;
return get(invoc, MODE_RESPONSE, shouldBlock);
|
static boolean | listen(int suiteId, java.lang.String classname, boolean request, boolean shouldBlock)Listen for a matching invocation.
When a matching invocation is present, true is returned.
Each Invocation instance is only returned once.
After it has been returned once; it is ignored subsequently.
if (suiteId == MIDletSuite.UNUSED_SUITE_ID || classname == null) {
throw new NullPointerException();
}
int mode = (request ? MODE_LREQUEST : MODE_LRESPONSE);
boolean pending = false;
int oldCancelCount = cancelCount;
while ((pending = listen0(suiteId, classname,
mode, shouldBlock)) == false &&
shouldBlock) {
// No pending request; retry unless cancelled
if (cancelCount > oldCancelCount) {
// Was cancelled; s == 0 -> no Invocation
break;
}
}
if (AppProxy.LOG_INFO) {
AppProxy.getCurrent().logInfo("Store listen: " + classname +
", request: " + request +
", pending: " + pending);
}
return pending;
|
private static native boolean | listen0(int suiteId, java.lang.String classname, int mode, boolean shouldBlock)Native method to listen for pending invocations with
matching suite, classname, and status. Cancel() will
also cause this method to return if blocked.
Each Invocation will only be returned once to prevent
multiple notifications.
|
static void | put(InvocationImpl invoc)Put a new Invocation into the store.
It can be modified by {@link #setStatus}.
The TID (transaction ID) is updated with a newly assigned value.
if (invoc.suiteId == MIDletSuite.UNUSED_SUITE_ID ||
invoc.classname == null) {
throw new NullPointerException();
}
put0(invoc);
if (AppProxy.LOG_INFO) {
AppProxy.getCurrent().logInfo("Store put0: " + invoc);
}
|
private static native void | put0(InvocationImpl invoc)Native method to store a new Invocation.
All of the fields of the InvocationImpl are stored.
|
static void | setCleanup(int suiteId, java.lang.String classname, boolean cleanup)Marks any existing invocations for the content handler.
Any marked invocation will be modified by {@link #getCleanup}.
if (AppProxy.LOG_INFO) {
AppProxy.getCurrent().logInfo("Store setCleanup: " + classname +
": " + cleanup);
}
setCleanup0(suiteId, classname, cleanup);
|
private static native void | setCleanup0(int suiteId, java.lang.String classname, boolean cleanup)Sets the cleanup flag in matching Invocations.
Any marked invocation will be modified by {@link #getCleanup}.
|
static void | setListenNotify(int suiteId, java.lang.String classname, boolean request)Reset the flags for requests or responses that are pending.
Once reset, any pending requests or responses will be
returned when listen0 is called.
if (suiteId == MIDletSuite.UNUSED_SUITE_ID || classname == null) {
throw new NullPointerException();
}
int mode = (request ? MODE_LREQUEST : MODE_LRESPONSE);
setListenNotify0(suiteId, classname, mode);
if (AppProxy.LOG_INFO) {
AppProxy.getCurrent().logInfo("Store setListenNotify: " +
classname +
", request: " + request);
}
|
private static native void | setListenNotify0(int suiteId, java.lang.String classname, int mode)Native method to reset the listen notified state for pending
invocations with matching suite, classname and status.
Each Invocation will only be returned once to prevent
multiple notifications.
|
static void | setParams(InvocationImpl invoc)Updates the parameters of the invocation in the native store.
The ID, URL, type, action, arguments, and data are
stored again in native.
setParams0(invoc);
if (AppProxy.LOG_INFO) {
AppProxy.getCurrent().logInfo("Store setParams0: " + invoc);
}
|
private static native void | setParams0(InvocationImpl invoc)Updates the parameters of the invocation in the native store.
The ID, URL, type, action, arguments, and data are
stored again in native.
|
static void | setStatus(InvocationImpl invoc)Sets the status of an existing Invocation.
If the status is OK, CANCELLED, ERROR, or INITIATED
and a response is required then the invocation is
requeued to the invoking application; if no response
is required the request is discarded and the transaction id (tid)
is set to zero.
setStatus0(invoc);
if (AppProxy.LOG_INFO) {
AppProxy.getCurrent().logInfo("Store setStatus0: " + invoc);
}
|
private static native void | setStatus0(InvocationImpl invoc)Sets the status of an existing Invocation
and handles response required behavior.
|
static int | size()Return the number of invocations in the native queue.
return size0();
|
private static native int | size0()Return the number of invocations in the native queue.
|