|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.j4me.util.ConnectorHelper
public class ConnectorHelper
Substitute for Connector.open
that forces a timeout on all platforms.
The (StreamConnection) Connector.open(url, Connector.READ, true)
call
is not guaranteed to timeout. On some phones this will cause indefinate
blocking and make the application unresponsive. To get around this the
connection must be made on a secondary thread that is killed after some
timeout period has expired.
Connector.open(java.lang.String, int, boolean)
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Method Summary | |
---|---|
javax.microedition.io.StreamConnection |
blockUntilConnected()
The owner should call this method to block until the connection is either established, has timed out, or encountered some other connection exception. |
static javax.microedition.io.Connection |
open(java.lang.String url,
int mode,
int timeout)
Create and open a Connection . |
void |
run()
Executed by thread to establish the connection when the owner calls start . |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public void run()
start
.
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public javax.microedition.io.StreamConnection blockUntilConnected() throws java.io.IOException, java.lang.SecurityException
null
if it timed
out and was unsuccessful.
java.io.IOException
- - If some other kind of I/O error occurs.
java.lang.SecurityException
- - May be thrown if access to the protocol
handler is prohibited.public static javax.microedition.io.Connection open(java.lang.String url, int mode, int timeout) throws java.lang.IllegalArgumentException, javax.microedition.io.ConnectionNotFoundException, java.io.IOException, java.lang.SecurityException
Connection
.
url
- is the URL for the connection.mode
- is the access mode. It is either Connector.READ
,
Connector.WRITE
, or Connector.READ_WRITE
.timeout
- is the the number of milliseconds before the open
attempt times out.
Connection
object.
java.lang.IllegalArgumentException
- if a parameter is invalid.
javax.microedition.io.ConnectionNotFoundException
- if the target of the name cannot be
found, or if the requested protocol type is not supported.
java.io.IOException
- if some other kind of I/O error occurs.
java.lang.SecurityException
- may be thrown if access to the protocol
handler is prohibited. Some platforms throw IOException
instead
to try to be MIDP 1.0 compatible.Connector.open(java.lang.String, int, boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |