Java Reference
In-Depth Information
Application Descriptor
The attributes in a MIDlet suite JAR are used by the application management software to run
MIDlets within a suite. The application descriptor, by contrast, contains information that helps
a device and/or the user decide whether or not to load a MIDlet suite. Because an application
descriptor is a file separate from the MIDlet suite JAR, it is easy for a device to load and examine
the file before downloading the MIDlet suite.
As it happens, a lot of the information in the application descriptor has to be the same as
the information that's in the MIDlet suite JAR. For example, the application descriptor must
contain the MIDlet-Name , MIDlet-Version , and MIDlet-Vendor attributes. In addition, it must
include the following:
MIDlet-Jar-URL : This is the URL where the MIDlet suite JAR can be found.
MIDlet-Jar-Size : This is the size, in bytes, of the MIDlet suite JAR.
The application descriptor can optionally contain the MIDlet-Description , MIDlet-Icon ,
MIDlet-Info-URL , and MIDlet-Data-Size attributes.
Devices and emulators vary widely in their handling of MIDlet suite descriptors. Some will
fail installation if any fields in the descriptor are incorrect, while others are more lenient. A tool
like the J2ME Wireless Toolkit is extremely useful in creating well-formed descriptors.
The application descriptor is useful in over the air (OTA) deployment. A device (and the
user) can download and inspect the descriptor, a relatively short file, before deciding whether
the entire MIDlet suite JAR should be downloaded and installed. For OTA provisioning, the server's
returned MIME type for the application descriptor should be text/vnd.sun.j2me.app-descriptor .
This and more (a whole protocol) is described in the “Over the Air User Initiated Provisioning
Specification” section of the MIDP 2.0 specification.
MIDlet Properties
There's one other possibility for attributes in the manifest or application descriptor. You can
add attributes that have meaning to your MIDlets. MIDlets can retrieve the values of these
attributes using the getAppProperty() method in the javax.microedition.midlet.MIDlet class.
An attribute can be listed in the application descriptor, JAR manifest, or both; if it is listed in
both, the value from the application descriptor will be used. In general, it makes sense to store
application properties in the application descriptor file. Because it's distinct from the MIDlet
suite JAR, the application descriptor can easily be changed to modify the behavior of your
MIDlets. You might, for example, store a URL or other configuration information in the appli-
cation descriptor.
For example, suppose you put an application-specific attribute in the application
descriptor, like this:
Jargoneer.url: http://www.dict.org/bin/Dict
Inside the MIDlet, you can retrieve the value of the attribute like this:
String url = getAppProperty("Jargoneer.url");
Search WWH ::




Custom Search