Methods Summary |
---|
private static void | checkMidlet(com.sun.midp.midlet.MIDletSuite midletSuite, java.lang.String midlet)Checks validity of midlet class name.
checkMidletRegistered(midletSuite, midlet);
/*
* IMPL_NOTE: strings in MIDlet-<n> attributes (see the check
* above) are not verified to be the names of classes that
* subclass javax.microedition.midlet.MIDlet, therefore we
* need this check
*/
final Class midletCls = Class.forName(midlet);
final boolean isMIDlet = javax.microedition.midlet.MIDlet.class
.isAssignableFrom(midletCls);
if (!isMIDlet) {
throw new ClassNotFoundException("Not a MIDlet");
}
|
static void | checkMidletRegistered(com.sun.midp.midlet.MIDletSuite midletSuite, java.lang.String midlet)Checks that the midlet is registered for the given suite.
// assert midletSuite != null;
// RFC: the check below might be unnecessary
if (midlet == null || midlet.length() == 0) {
throw new ClassNotFoundException("MIDlet missing");
}
if (!midletSuite.isRegistered(midlet)) {
throw new ClassNotFoundException("No MIDlet-<n> registration");
}
|
public static java.lang.String | getFilter(java.lang.String connection)Retrieve the registered filter for a requested connection.
/* Verify that the connection requested is valid. */
if (connection == null || connection.length() == 0) {
return null;
}
return ConnectionRegistry.getFilter(connection);
|
public static java.lang.String | getMIDlet(java.lang.String connection)Retrieve the registered MIDlet for a requested connection.
/* Verify that the connection requested is valid. */
if (connection == null || connection.length() == 0) {
return null;
}
return ConnectionRegistry.getMIDlet(connection);
|
private static com.sun.midp.midlet.MIDletSuite | getMIDletSuite()Gets a midlet suite object.
return MIDletStateHandler
.getMidletStateHandler()
.getMIDletSuite();
|
public static java.lang.String[] | listConnections(boolean available)Return a list of registered connections for the current
MIDlet suite.
final MIDletSuite midletSuite = getMIDletSuite();
if (midletSuite == null) {
return null;
}
return ConnectionRegistry.listConnections(midletSuite, available);
|
public static long | registerAlarm(java.lang.String midlet, long time)Register a time to launch the specified application. The
PushRegistry supports one outstanding wake up
time per MIDlet in the current suite. An application
is expected to use a TimerTask for notification
of time based events while the application is running.
If a wakeup time is already registered, the previous value will
be returned, otherwise a zero is returned the first time the
alarm is registered.
final MIDletSuite midletSuite = getMIDletSuite();
if (midletSuite == null) {
throw new IllegalStateException("Not in a MIDlet context");
}
checkMidlet(midletSuite, midlet);
try {
midletSuite.checkForPermission(Permissions.PUSH, null);
} catch (InterruptedException ie) {
throw new RuntimeException(
"Interrupted while trying to ask the user permission");
}
return ConnectionRegistry.registerAlarm(midletSuite, midlet, time);
|
public static void | registerConnection(java.lang.String connection, java.lang.String midlet, java.lang.String filter)Register a dynamic connection with the
application management software. Once registered,
the dynamic connection acts just like a
connection preallocated from the descriptor file.
The internal implementation includes the storage name
that uniquely identifies the MIDlet .
final Connection c = Connection.parse(connection);
// Quick check of filter to be spec complaint
if (filter == null) {
throw new IllegalArgumentException("filter is null");
}
final MIDletSuite midletSuite = getMIDletSuite();
/* This method should only be called by running MIDlets. */
if (midletSuite == null) {
throw new IllegalStateException("Not in a MIDlet context");
}
/*
* Validate parameters and Push connection availability
*/
checkMidlet(midletSuite, midlet);
/*
* IMPL_NOTE: as checkRegistration will need to parse
* connection and filter anyway, it might be a good
* idea to save the results
*/
ConnectionRegistry.checkRegistration(c, midlet, filter);
/*
* Check permissions.
*/
try {
midletSuite.checkForPermission(Permissions.PUSH, null);
} catch (InterruptedException ie) {
throw new InterruptedIOException(
"Interrupted while trying to ask the user permission");
}
ConnectionRegistry.registerConnection(midletSuite, c, midlet, filter);
|
public static boolean | unregisterConnection(java.lang.String connection)Remove a dynamic connection registration.
/* Verify the connection string before using it. */
if (connection == null || connection.length() == 0) {
return false;
}
final MIDletSuite midletSuite = getMIDletSuite();
if (midletSuite == null) {
return false;
}
return ConnectionRegistry.unregisterConnection(midletSuite, connection);
|