FileDocCategorySizeDatePackage
CHManager.javaAPI DocphoneME MR2 API (J2ME)7535Wed May 02 18:00:08 BST 2007com.sun.midp.content

CHManager

public class CHManager extends Object
Stub interface to handle ContentHandlers functions. If ContentHandlers are not supported it provides a no-op implementation. The "real" Content Handler implementation is {@link com.sun.midp.content.CHInstallerImpl}. The methods here are called at by the {@link Installer} at the appropriate times to {@link #preInstall parse and verify the JAD/Manifest attributes} and {@link #install remove old content handlers and register new ones}. When a suite is to be removed the content handlers are {@link #uninstall uninstalled}. At startup {@link #initCleanupMonitor} to initialize any necessary cleanup handling when the application exits. When a MIDlet is about to created the {@link #midletAdded} method is called. When a MIDlet has been destroyed the {@link #midletRemoved} method is called.

The {@link GraphicalInstaller}, when it is invoked, calls the Invocation mechanism via the {@link #getInstallURL} method to check if a URL is available and should be installed. When it succeeds or fails the {@link #installDone} method is called to complete the invocation. The registration of the GraphicalInstaller as a content handler for the types and suffixes for java archives and java application descriptors is handled by {@link com.sun.midp.content.Registry#initGraphicalInstaller}.

see
GraphicalInstaller
see
Installer
see
CHInstallerImpl

Fields Summary
private static CHManager
manager
The CHManager instance for this application context.
Constructors Summary
protected CHManager()
Creates a new instance of CHInstaller.

    
Methods Summary
public java.lang.StringgetInstallURL(javax.microedition.midlet.MIDlet midlet)
Check for a URL to install from the Invocation mechanism, if one has been queued.

param
midlet the MIDlet that is the content handler.
return
the URL to install; null if none is available
see
com.sun.midp.content.CHInstallerImpl

	return null;
    
public static com.sun.midp.content.CHManagergetManager(com.sun.midp.security.SecurityToken token)
Get the Content Handler manager if the system is configured to implement content handlers. A dummy handler is returned if content handlers are not supported.

param
token the SecurityToken to get the CHManager
return
the CHInstaller instance to be used to handle management and installation of content handlers.
see
com.sun.midp.content.CHInstaller
exception
SecurityException if the token or suite is not allowed

        if (token != null) {
            token.checkIfPermissionAllowed(Permissions.MIDP);
        } else {
            MIDletSuite msuite =
                MIDletStateHandler.getMidletStateHandler().getMIDletSuite();
            if (msuite != null) {
                msuite.checkIfPermissionAllowed(Permissions.AMS);
            }
        }

	if (manager == null) {
	    try {
		Class cl = Class.forName("com.sun.midp.content.CHManagerImpl");
		manager = (CHManager)cl.newInstance();
	    } catch (Exception t) {
		// No real ContentHandler manager is available, return a noop
		manager = new CHManager();
	    }
	}
	return manager;
    
public voidinitCleanupMonitor(com.sun.midp.main.MIDletProxyList midletProxyList)
Setup to monitor for MIDlets exiting and check for incompletely handled Invocation requests.

param
midletProxyList reference to the MIDlet proxy list

    
public voidinstall()
Install the content handlers found and verified by preInstall. Register any content handlers parsed from the JAD/Manifest attributes.

exception
InvalidJadException thrown if the application descriptor is invalid

    
public voidinstallDone(boolean success)
Notify the invocation mechanism that the install of the URL provided by {@link #getURLToInstall} succeeded or failed.

param
success true if the install was a success; false otherwise
see
com.sun.midp.content.CHInstallerImpl

    
public voidmidletInit(int suiteId, java.lang.String classname)
Notification that a MIDlet is about to be created. Stub implementation used when CHAPI is not present.

param
suiteId the storage name of the MIDlet suite
param
classname the midlet classname
see
com.sun.midp.midlet.MIDletState

    
public voidpreInstall(com.sun.midp.installer.Installer installer, com.sun.midp.installer.InstallState state, com.sun.midp.midlet.MIDletSuite msuite, java.lang.String authority)
Parse the ContentHandler attributes and check for errors.
  • Parse attributes into set of ContentHandlers.
  • If none, return
  • Check for permission to install handlers
  • Check each for simple invalid arguments
  • Check each for MIDlet is registered
  • Check each for conflicts with other application registrations
  • Find any current registrations
  • Merge current dynamic current registrations into set of new
  • Check and resolve any conflicts between static and curr dynamic
  • Retain current set and new set for registration step.

param
installer the installer with access to the JAR, etc.
param
state the InstallState with the attributes and other context
param
msuite access to information about the suite
param
authority the authority, if any, that authorized the trust level
exception
InvalidJadException if there is no classname field, the option field is not "true", "false" or blank or if there are more than five comma separated fields on the line.

    
public voiduninstall(int suiteId)
Uninstall the Content handler specific information for the specified suiteId.

param
suiteId the suite ID