Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed


email article
printer friendly
get the code
more resources

IXC Simplifies Xlet Communication
Similar to RMI, Personal Profile's inter-Xlet communication lets Xlets talk to each other
by Xiaozhong Wang

June 2003 Issue


Copyright 2003 Sun Microsystems Inc. All rights reserved. Used by permission. Any use of the code samples in this article is governed by the license terms available at the java.sun.com site (see Resources). Sun, Sun Microsystems, the Sun logo, J2ME, PersonalJava, J2SE, and The Network Is The Computer are trademarks or registered trademarks of Sun Microsystems Inc. in the United States and other countries.

ADVERTISEMENT

Sun Microsystems' recent release of Java 2 Platform, Micro Edition (J2ME) Personal Profile, which replaces PersonalJava Technology, provides a complete application environment for the high-end PDA market. One important feature in Personal Profile (as well as Personal Basis Profile) is the Xlet application model, which basically has two elements: the Xlet life cycle and inter-Xlet communication (IXC). "J2ME Gets Personal," by David Hemphill (Java Pro, December 2002), provides a nice introduction to the Xlet life cycle. Now let's look at IXC.

Why do you need IXC? Imagine a PDA that uses Personal Profile as the platform and includes an Xlet management facility that runs Xlets. Users can download third-party applications that are written as Xlets to run on this PDA. One Xlet is served as a simple database engine to provide database services to other Xlets. This scenario is a typical client-server programming model. How can other Xlets make use of the database Xlet? You cannot directly access objects in the database Xlet because different class loaders load different Xlets. You can use some traditional interprocess communication techniques, but those may be complicated. Remote Method Invocation (RMI) looks like a good solution, but the Personal Profile specification does not include RMI. (You could use RMI, though, if the platform also includes the J2ME RMI Optional Package.) There should be some easy way for an Xlet to provide services to and make use of other Xlets. That is where IXC kicks in.

Before going to IXC, let's go over some basic Xlet concepts. Xlets are like applets in Java 2 Platform, Standard Edition (J2SE). They must be run in some Xlet management utility, just like Applets must be run in a browser or AppletViewer. An Xlet can have four states in its life cycle: loaded, paused, active, and destroyed. To write an Xlet, you must implement four methods defined in the Xlet interface:

public interface Xlet {

   public void initXlet(
      XletContext ctx) 
      throws 
         XletStateChangeException;

   public void startXlet() 
      throws 
         XletStateChangeException;

   public void pauseXlet();

   public void destroyXlet(
      boolean unconditional) throws 
         XletStateChangeException;
}
Back to top












Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTPOnline Home