FileDocCategorySizeDatePackage
PushRegistryInternal.javaAPI DocphoneME MR2 API (J2ME)9431Wed May 02 18:00:00 BST 2007com.sun.midp.io.j2me.push

PushRegistryInternal

public final class PushRegistryInternal extends Object
Internal push functionality for CLDC stack.

Fields Summary
public static final int
PUSH_OPT_WHEN_ONLY_APP
Push option to only launch this suite when not other applications are running.
Constructors Summary
private PushRegistryInternal()
Hides the default constructor.


             
       
Methods Summary
public static booleancheckInConnectionInternal(com.sun.midp.security.SecurityToken token, java.lang.String connection)
Check in a push connection into AMS so the owning MIDlet can get launched next time data is pushed. This method is used when a MIDlet will not be able to get the connection and close (check in) the connection for some reason. (normally because the user denied a permission)

For datagram connections this function will discard the cached message.

For server socket connections this function will close the accepted connection.

param
token security token of the calling class
param
connection generic connection protocol, host and port number (optional parameters may be included separated with semi-colons (;))
exception
IllegalArgumentException if the connection string is not valid
exception
SecurityException if the MIDlet does not have permission to clear a connection
return
true if the check in was successful, false the connection was not registered.
see
#unregisterConnection

        if (token == null) {
            throw new SecurityException("This API is for internal use only");
        }
        token.checkIfPermissionAllowed(Permissions.AMS);
        return ConnectionRegistry.checkInConnectionInternal(connection);
    
private static voidcheckInvocationAllowed()
Validates that the method is invoked allowed party.

        final MIDletSuite current =
            MIDletStateHandler.getMidletStateHandler().getMIDletSuite();

        if (current != null) {
            current.checkIfPermissionAllowed(Permissions.AMS);
        }
    
public static voidenablePushLaunch(boolean enable)
Sets the flag which enables push launches to take place.

param
enable set to true to enable launching of MIDlets based on alarms and connection notification events, otherwise set to false to disable launches

        checkInvocationAllowed();
        ConnectionRegistry.pushEnabled = enable;
    
public static voidinitSecurityToken(com.sun.midp.security.SecurityToken token)
Initializes the security token for this class, so it can perform actions that a normal MIDlet Suite cannot.

param
token security token for this class.

        checkInvocationAllowed();
        ConnectionRegistry.initSecurityToken(token);
    
public static java.lang.StringlistConnections(int id, boolean available)
Return a list of registered connections for given MIDlet suite.

param
id identifies the specific MIDlet suite to be launched
param
available if true, only return the list of connections with input available
return
array of connection strings, where each connection is represented by the generic connection protocol, host and port number identification

        checkInvocationAllowed();
        return ConnectionRegistry.listConnections(id, available);
    
public static voidregisterConnectionInternal(com.sun.midp.midlet.MIDletSuite midletSuite, java.lang.String connection, java.lang.String midlet, java.lang.String filter, boolean bypassChecks)
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. This method bypasses the class loader specific checks needed by the Installer.

param
midletSuite MIDlet suite for the suite registering, the suite only has to implement isRegistered, checkForPermission, and getID.
param
connection generic connection protocol, host and port number (optional parameters may be included separated with semi-colons (;))
param
midlet class name of the MIDlet to be launched, when new external data is available
param
filter a connection URL string indicating which senders are allowed to cause the MIDlet to be launched
param
bypassChecks if true, bypass the permission checks, used by the installer when redo old connections during an aborted update
exception
IllegalArgumentException if the connection string is not valid
exception
ConnectionNotFoundException if the runtime system does not support push delivery for the requested connection protocol
exception
IOException if the connection is already registered or if there are insufficient resources to handle the registration request
exception
ClassNotFoundException if the MIDlet class name can not be found in the current MIDlet suite
exception
SecurityException if the MIDlet does not have permission to register a connection
see
#unregisterConnection


        checkInvocationAllowed();

        if (filter == null) {
            throw new IllegalArgumentException("filter is null");
        }

        if (!bypassChecks) {
            try {
                midletSuite.checkForPermission(Permissions.PUSH, null);
            } catch (InterruptedException ie) {
                throw new InterruptedIOException(
                    "Interrupted while trying to ask the user permission");
            }

            PushRegistryImpl.checkMidletRegistered(midletSuite, midlet);

            ConnectionRegistry.checkRegistration(Connection.parse(connection), midlet, filter);
        }

        ConnectionRegistry.registerConnectionInternal(
                midletSuite,
                connection, midlet, filter,
                !bypassChecks);
    
public static voidsetMvmSingleMidletMode()
Sets the flag which indicates that the AMS is operating in MVM single MIDlet mode.

        checkInvocationAllowed();
        ConnectionRegistry.mvmSingleMidletMode = true;
    
public static voidstartListening()
Start listening for push notifications. Will throw a security exception if called by any thing other than the MIDletSuiteLoader.

        checkInvocationAllowed();
        ConnectionRegistry.startListening();
    
public static voidunregisterConnections(int id)
Unregister all the connections for a MIDlet suite.

param
id identifies the specific MIDlet suite

        checkInvocationAllowed();
        ConnectionRegistry.delAllForSuite0(id);