FileDocCategorySizeDatePackage
ProtocolPushImpl.javaAPI DocphoneME MR2 API (J2ME)6775Wed May 02 18:00:42 BST 2007gov.nist.core

ProtocolPushImpl

public class ProtocolPushImpl extends com.sun.midp.io.j2me.push.ProtocolPush
Implementation of push behaviour.

Fields Summary
private static ProtocolPushImpl
pushInstance
Instance
Constructors Summary
Methods Summary
public voidcheckRegistration(java.lang.String connection, java.lang.String midlet, java.lang.String filter)
Called when registration is checked.

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
exception
IllegalArgumentException if the connection string is not valid
exception
ClassNotFoundException if the MIDlet class name can not be found in the current MIDlet suite

    
protected com.sun.midp.io.j2me.push.ProtocolPushgetInstance()
Get instance of this class.

return
class instance

        if (pushInstance == null) {
            pushInstance = new ProtocolPushImpl();
        }
        return (ProtocolPush)pushInstance;
    
public voidregisterConnection(com.sun.midp.midlet.MIDletSuite midletSuite, java.lang.String connection, java.lang.String midlet, java.lang.String filter)
Called when registration is established.

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
exception
IllegalArgumentException if the connection string is not valid
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


        checkIsNotHost(connection, false);

        if (connection.startsWith(SIPConstants.SCHEME_SIP
            .toLowerCase() + ":")) {
            try {
                Class.forName("com.sun.midp.io.j2me.sip.Protocol");
            } catch (ClassNotFoundException e) {
                throw new ConnectionNotFoundException(
                    "Connection not supported");
            }

            /*
             * Check the suite permission for the connection
             * and close the connection immediately.
             */
            try {
                midletSuite.checkForPermission(Permissions.SIP,
                    connection);
            } catch (InterruptedException ie) {
                throw new InterruptedIOException(
                    "Interrupted while trying to ask the user permission");
            }

            /*
             * Verify the connection string.
             */
            URLParser parser = new URLParser(connection);
            SipURI inputURI = null;
            try {
                inputURI = (SipURI)parser.parse();
            } catch (ParseException exc) {
                throw new IllegalArgumentException(exc.getMessage());
            }
        } else if (connection.startsWith(SIPConstants.SCHEME_SIPS
            .toLowerCase() + ":")) {
            try {
                Class.forName("com.sun.midp.io.j2me.sips.Protocol");
            } catch (ClassNotFoundException e) {
                throw new ConnectionNotFoundException(
                    "Connection not supported");
            }

            /*
             * Check the suite permission for the connection
             * and close the connection immediately.
             */
            try {
                midletSuite.checkForPermission(Permissions.SIPS,
                    connection);
            } catch (InterruptedException ie) {
                throw new InterruptedIOException(
                    "Interrupted while trying to ask the user permission");
            }

            /*
             * IMPL_NOTE: Currently SIPS push connections are not supported.
             * Throwing an exception here prevents the sips connection
             * URL from being registered.
             */
            throw new ConnectionNotFoundException(
                    "Connection not supported");
        }