FileDocCategorySizeDatePackage
AppIsolateMIDletSuiteLoader.javaAPI DocphoneME MR2 API (J2ME)5624Wed May 02 18:00:04 BST 2007com.sun.midp.main

AppIsolateMIDletSuiteLoader

public class AppIsolateMIDletSuiteLoader extends CldcMIDletSuiteLoader
The first class loaded in an application Isolate by the MIDP AMS to initialize internal security and start a MIDlet suite.

Fields Summary
protected static boolean
inUse
Guards against multiple use in an Isolate.
protected com.sun.cldc.isolate.Isolate
currentIsolate
Cached reference to the current Isolate
protected MIDletExecuteEventProducer
midletExecuteEventProducer
Event producer to send events for other MIDlets execution
Constructors Summary
private AppIsolateMIDletSuiteLoader(String[] args)
Creates class instance and gets suite parameters from array with arguments

param
args the arguments passed to main class of the Isolate

        this.suiteId = Integer.parseInt(args[0]);
        this.midletClassName = args[1];
        this.midletDisplayName = args[2];
        this.args = new String[] {args[3], args[4], args[5]};
        this.externalAppId = Integer.parseInt(args[6]);
    
Methods Summary
protected booleanallocateReservedResources()
Allocates resources for a suite task according to global resource policy

        return allocateReservedResources0();
    
private static native booleanallocateReservedResources0()
Allocates reserved resources for the given isolate.

return
true if the reserved resources are available otherwise false

protected voidcreateSuiteEnvironment()
Extends base class implementation with creation of additional event producers

        super.createSuiteEnvironment();

        // Create event producer to execute other MIDlets
        // from non-AMS tasks
        midletExecuteEventProducer =
            new MIDletExecuteEventProducer(
                internalSecurityToken,
                eventQueue,
                amsIsolateId);
    
protected voidexitLoader()
Exits suite loader Isolate with proper exit code.

        currentIsolate.exit(0);
    
private native voidfinalize()
Native cleanup code, called when this isolate is done, even if killed.

private static native voidhandleFatalError(java.lang.Throwable t)
Handles a fatal error

param
t the Throwable that caused the fatal error

protected voidinit()
Inits suite loader instance

        currentIsolate = Isolate.currentIsolate();
        super.init();
    
protected voidinitSuiteEnvironment()
Extends base class implementation with MVM specific initializtion of the AmsUtil class

        super.initSuiteEnvironment();

        AmsUtil.initClassInAppIsolate(
            midletExecuteEventProducer);
    
public static voidmain(java.lang.String[] args)
Called for isolates other than the initial one. Initializes internal security, and starts the MIDlet.

param
args arg[0] the suite ID, arg[1] the class name of the MIDlet, arg[2] the name of the MIDlet to display, arg[3] optional MIDlet arg 0, arg[4] optional MIDlet arg 1, arg[5] optional MIDlet arg 2

        try {
            /* This class shouldn't be used more than once. */
            if (inUse) {
                throw new IllegalStateException();
            }
            
            inUse = true;
            new AppIsolateMIDletSuiteLoader(args).runMIDletSuite();
        } catch (Throwable t) {
            handleFatalError(t);
        }
    
protected voidreportError(int errorCode, java.lang.String details)
Posts suite task error to event system.

param
errorCode the error code to report
param
details text with error details

        midletControllerEventProducer.sendMIDletStartErrorEvent(
            suiteId, midletClassName, externalAppId,
            errorCode, details);
    
protected voidrestrictAPIAccess()
Restricts suite access to internal API

        if (midletSuite.checkPermission(
            Permissions.getName(Permissions.AMS)) != 1) {

            // Permission is not allowed.
            //
            // Shutdown access to Isolate references before a MIDlet is
            // loaded. This will not effect the reference already obtained.
            currentIsolate.setAPIAccess(false);
        }