Methods Summary |
---|
private static void | broadcast(int event)
synchronized (mHandlerMap) {
Collection values = mHandlerMap.values();
Iterator iter = values.iterator();
while (iter.hasNext()) {
ChunkHandler handler = (ChunkHandler) iter.next();
switch (event) {
case CONNECTED:
handler.connected();
break;
case DISCONNECTED:
handler.disconnected();
break;
default:
throw new UnsupportedOperationException();
}
}
}
|
private static Chunk | dispatch(int type, byte[] data, int offset, int length)
ChunkHandler handler;
synchronized (mHandlerMap) {
/*
* If registration hasn't completed, and we haven't timed out
* waiting for it, wait a bit.
*/
while (!mRegistrationComplete && !mRegistrationTimedOut) {
//System.out.println("dispatch() waiting for reg");
try {
mHandlerMap.wait(1000); // 1.0 sec
} catch (InterruptedException ie) {
continue;
}
if (!mRegistrationComplete) {
/* timed out, don't wait again */
System.out.println("DDM dispatch reg wait timeout");
mRegistrationTimedOut = true;
}
}
handler = mHandlerMap.get(type);
}
//System.out.println(" dispatch cont");
if (handler == null) {
System.err.println("Can't dispatch DDM chunk "
+ Integer.toHexString(type) + ": no handler defined");
return null;
}
Chunk chunk = new Chunk(type, data, offset, length);
return handler.handleChunk(chunk);
|
private static native void | nativeSendChunk(int type, byte[] data, int offset, int length)
|
public static void | registerHandler(int type, ChunkHandler handler)Register an instance of the ChunkHandler class to handle a specific
chunk type.
Throws an exception if the type already has a handler registered.
if (handler == null)
throw new NullPointerException();
synchronized (mHandlerMap) {
if (mHandlerMap.get(type) != null)
throw new RuntimeException("type " + Integer.toHexString(type)
+ " already registered");
mHandlerMap.put(type, handler);
}
|
public static void | registrationComplete()The application must call here after it finishes registering
handlers.
// sync on mHandlerMap because it's convenient and makes a kind of
// sense
synchronized (mHandlerMap) {
mRegistrationComplete = true;
mHandlerMap.notifyAll();
}
|
public static void | sendChunk(Chunk chunk)Send a chunk of data to the DDM server. This takes the form of a
JDWP "event", which does not elicit a response from the server.
Use this for "unsolicited" chunks.
nativeSendChunk(chunk.type, chunk.data, chunk.offset, chunk.length);
|
public static ChunkHandler | unregisterHandler(int type)Unregister the existing handler for the specified type.
Returns the old handler.
synchronized (mHandlerMap) {
return mHandlerMap.remove(type);
}
|