| java.lang.Object com.sun.midp.midlet.MIDletStateHandler
MIDletStateHandler | public class MIDletStateHandler (Code) | | The MIDletStateHandler starts and controls MIDlets through the lifecycle
states.
MIDlets are created using its no-arg Constructor. Once created
a MIDlet is sequenced through the ACTIVE ,
PAUSED , and DESTROYED states.
The MIDletStateHandler is a singleton for the suite being run and
is retrieved with getMIDletStateHandler(). This allow the
MIDletStateHandler to be the anchor of trust internally for the MIDP API,
restricted methods can obtain the MIDletStateHandler for a MIDlet suite
inorder to check the properties and actions of a suite.
Because of this, there MUST only be one a MIDlet suite per
MIDletStateHandler. In addition a method can assume that the application
manager is the caller if there is no suite started.
The MIDlet methods are protected in the javax.microedition.midlet package
so the MIDletStateHandler can not call them directly. The MIDletState
object and
MIDletTunnel subclass class allow the MIDletStateHandler to hold the state
of the
MIDlet and to invoke methods on it. The MIDletState instance is created
by the MIDlet when it is constructed.
This implementation of the MIDletStateHandler introduces
extra internal MIDlet states to allow processing of MIDlet
requested state changes in the control thread and serialized with
other state changes. The additional states are:
-
ACTIVE_PENDING - The MIDlet is still PAUSED but
will be ACTIVE after startApp is called when the state is
next processed.
-
PAUSE_PENDING - The MIDlet is still ACTIVE but
will be PAUSED after pauseApp is called when the state is
next processed.
-
DESTROY_PENDING - Indicates that the MIDlet needs
to be DESTROYED . The MIDlet's destroyApp has not yet been
called.
The MIDletStateHandler loops, looking for MIDlets that require state changes
and making the requested changes including calling methods in
the MIDlet to make the change.
When a MIDlet's state is changed to ACTIVE ,
PAUSED , or DESTROYED the MIDlet state listener
is notified of the change, which in turn sends the notification onto
the central AMS.
See Also: MIDlet See Also: MIDletPeer See Also: MIDletLoader See Also: MIDletStateHandler |
Method Summary | |
public void | destroySuite() Destroys all running MIDlets in this suite only. | public String | getFirstRunningMidlet() Gets the class name first midlet in the list of running MIDlets. | public MIDletEventConsumer | getMIDletEventConsumer(SecurityToken token, String name) Gets MIDlet event consumer of the named MIDlet . | public static int | getMIDletState(MIDlet midlet) Retrieves current state of the MIDlet given. | public MIDletSuite | getMIDletSuite() Provides a object with a mechanism to retrieve
MIDletSuite being run. | public static synchronized MIDletStateHandler | getMidletStateHandler() Gets the MIDletStateHandler that manages the lifecycle states of
MIDlets running in an Isolate.
If the instance of the MIDletStateHandler has already been created
it is returned. | public void | initMIDletStateHandler(SecurityToken token, MIDletStateListener theMIDletStateListener, MIDletLoader theMidletLoader, PlatformRequest thePlatformRequestHandler) Initializes MIDlet State Handler. | public boolean | isRunning(String name) Checks if the named MIDlet has already been instantiated. | public static MIDletPeer | newMIDletPeer(SecurityToken token, MIDlet m) Called by the MIDlet constructor to a new MIDletPeer object.
Parameters: token - security token for authorizing the caller Parameters: m - the MIDlet for which this state is being created;must not be null . | public void | startMIDlet(String classname, String displayName) Starts a MIDlet from outside of the package. | public void | startMIDlet(int externalAppId, String classname, String displayName) Starts a MIDlet from outside of the package. | public void | startMIDlet(SecurityToken token, String classname, String displayName) Starts a MIDlet from outside of the package. | public void | startMIDlet(SecurityToken token, int externalAppId, String classname, String displayName) Starts a MIDlet from outside of the package. | public void | startSuite(MIDletSuiteExceptionListener exceptionHandler, MIDletSuite aMidletSuite, int externalAppId, String classname) Runs MIDlets until there are none. |
destroySuite | public void destroySuite()(Code) | | Destroys all running MIDlets in this suite only. This method is only
used by the push registry in single VM mode.
|
getFirstRunningMidlet | public String getFirstRunningMidlet()(Code) | | Gets the class name first midlet in the list of running MIDlets.
the classname or null if no midlet are running |
getMIDletEventConsumer | public MIDletEventConsumer getMIDletEventConsumer(SecurityToken token, String name)(Code) | | Gets MIDlet event consumer of the named MIDlet .
Parameters: token - security token for authorizing the caller Parameters: name - class name of MIDlet reference of the MIDlet event consumer |
getMIDletState | public static int getMIDletState(MIDlet midlet)(Code) | | Retrieves current state of the MIDlet given.
Parameters: midlet - the MIDlet of interest the MIDlet state as defined in MIDletPeer class |
getMIDletSuite | public MIDletSuite getMIDletSuite()(Code) | | Provides a object with a mechanism to retrieve
MIDletSuite being run.
MIDletSuite being run |
getMidletStateHandler | public static synchronized MIDletStateHandler getMidletStateHandler()(Code) | | Gets the MIDletStateHandler that manages the lifecycle states of
MIDlets running in an Isolate.
If the instance of the MIDletStateHandler has already been created
it is returned. If not it is created.
The instance becomes the MIDletStateHandler for this suite.
The fact that there is one handler per Isolate
is a security feature. Also a security feature, is that
getMIDletStateHandler is
static, so API can find out what suite is calling, if in the future
multiple suites can be run in the same VM, the MIDlet state handler
for each suite
should be loaded in a different classloader or have some other way
having multiple instances of static class data.
the MIDlet state handler for this Isolate |
initMIDletStateHandler | public void initMIDletStateHandler(SecurityToken token, MIDletStateListener theMIDletStateListener, MIDletLoader theMidletLoader, PlatformRequest thePlatformRequestHandler)(Code) | | Initializes MIDlet State Handler.
Parameters: token - security token for initilaization Parameters: theMIDletStateListener - processes MIDlet states in aVM specific way Parameters: theMidletLoader - loads a MIDlet in a VM specific way Parameters: thePlatformRequestHandler - the platform request handler |
isRunning | public boolean isRunning(String name)(Code) | | Checks if the named MIDlet has already been instantiated.
Parameters: name - class name of MIDlet to test ifcurrently run true if an instance of the MIDlet is alreadyrunning |
newMIDletPeer | public static MIDletPeer newMIDletPeer(SecurityToken token, MIDlet m)(Code) | | Called by the MIDlet constructor to a new MIDletPeer object.
Parameters: token - security token for authorizing the caller Parameters: m - the MIDlet for which this state is being created;must not be null . the preallocated MIDletPeer for the MIDlet being constructed byMIDletStateHandler.createMIDlet exception: SecurityException - AMS permission is not granted andif is constructor is not being called in the context ofcreateMIDlet . |
startSuite | public void startSuite(MIDletSuiteExceptionListener exceptionHandler, MIDletSuite aMidletSuite, int externalAppId, String classname) throws ClassNotFoundException, InstantiationException, IllegalAccessException(Code) | | Runs MIDlets until there are none.
Handle any pending state transitions of any MIDlet.
If there are none, wait for transitions.
If there is no foreground MIDlet select one that is ACTIVE and
has setCurrent != null.
If the foreground MIDlet changes from the ACTIVE_FOREGROUND state
it automatically looses the foreground and and new one is selected.
Parameters: exceptionHandler - the handler for midlet execution exceptions. Parameters: aMidletSuite - the current midlet suite Parameters: externalAppId - ID of given by an external application manager Parameters: classname - name of MIDlet class exception: ClassNotFoundException - is thrown, if the MIDlet main class isnot found exception: InstantiationException - is thrown, if the MIDlet can not becreated exception: IllegalAccessException - is thrown, if the MIDlet is notpermitted to perform a specific operation |
|
|