Java Reference
In-Depth Information
CHAPTER 9
Introducing Xlets and the
Personal Basis Profile
T he initial runtime environment for Java applets was the browser, but the advent of Java
ME has changed that. As you saw in Chapter 4, the MIDlet is the MIDP's answer to an
application runtime; in this chapter, you will see how the Xlet plays the same role for the
Personal Basis Profile (PBP) atop the CDC. Unsurprisingly, the responsibilities an Xlet ful-
fils are essentially the same as those of a MIDlet, so if you're acquainted with the MIDlet,
what you see here will be quite familiar.
In this chapter, I discuss the Xlet execution model. After reading this chapter, you will
understand both the origin of the Xlet in the Java ME environment as well as the life cycle
of an Xlet. You will be able to write your own Xlets, as well as perform basic inter-Xlet
application communication using the interfaces available in the PBP.
Understanding the Xlet
The Xlet model comes to Java ME by way of Sun's foray into the television space for Java
applications. Now part of the PBP atop the CDC, the Xlet model must meet some addi-
tional criteria above and beyond what a simple applet must; notably, it must permit
multiple applications to share device resources, including the I/O devices. It also must
ensure that no single application can bring down the Java virtual machine, as the virtual
machine may be hosting other applications at the same time. Consequently, the Xlet
must have a specific life cycle, letting the Xlet operate in active—running—and paused
states, just like a MIDlet.
As with the MIDlet, you implement an Xlet by extending a specific interface—
specifically, the javax.microedition.xlet.Xlet interface. As the runtime initializes the
Xlet, it provides a context , which gives your Xlet some key methods to interact with the
application runtime.
223
 
Search WWH ::




Custom Search