Devices in a peer-to-peer (P2P) network talk directly to each other instead of using central servers. The traditional approach to computing on the World-Wide Web is a star pattern of client computers grouped around a central server. In P2P networks devices connect directly to each other, forming a flexible, decentralized network fabric. The P2P model is particularly interesting to wireless developers because it enables them to assemble ad hoc networks quickly, without imposing configuration chores on users. In the wired world, networking is somewhat stable and dependable. Wireless networking is usually less reliable because it's subject to the vagaries of electromagnetic wave propagation, interference, and battery exhaustion. Devices may come and go without warning or visible reason. P2P networking provides a model that is well suited to the vicissitudes of wireless devices.
In this article, you'll learn about a set of protocols for P2P networking
called JXTA (the name is derived from the word "juxtapose"),
how these protocols are extended to MIDP, and how to install and run JXTA
demonstration programs for MIDP. Introduction to JXTA The
JXTA 1.0 protocols
support various aspects of P2P
networking, including the discovery of other computers and services
and the ability to exchange information or invoke services. The JXTA specifications are simply communications protocols; they do not mandate particular hardware or software. The protocols are being implemented in many different languages. Two complete implementations are available, one written in the Java programming language, the other in C. JXTA peers communicate by exchanging XML messages. Messages called advertisements announce the availability of a peer. The JXTA protocols and reference implementation are developed by an open community. For more details about JXTA, see:
Introduction to JXTA for J2ME The goal of the JXME project is to bring JXTA functionality to MIDP devices. Several requirements in the JXTA protocols make it hard to implement on MIDP:
Because the basic requirements of the JXTA protocols exceed the minimum requirements of MIDP, the JXME architecture relies on a JXTA relay to do most of the heavy lifting. The JXTA relay is the true JXTA peer; it participates in the JXTA network on behalf of one or more J2ME devices. Connected devices use a simplified protocol, and exchange HTTP-based binary messages with the JXTA relay. Running the Examples "Enough yappin'!" you say. "Get to the good stuff." There are two ways to run the JXME demonstrations. This section describes how to download the built applications (binaries) and run them using the J2ME Wireless Toolkit. If you want to get your hands a little dirtier, read the next section to learn how to download the source code, and build and run the examples yourself. To run the JXME demonstrations, you will need to have installed the J2ME Wireless Toolkit. Download jxme.zip and unzip it in the location of your choice. The resulting midp/demo/chat/dist directory contains the chat application, packaged as chat.jad and chat.jar. From the J2ME Wireless Toolkit, simply double-click on chat.jad to start the application in the MIDP emulator. That's it. Note that two other demonstrations are included: a Tic-Tac-Toe MIDlet, which should also be double-clickable, and a chat implementation for Personal Profile clients. While you are welcome to experiment with these, this article discusses only the chat application for MIDP. If you don't want to find out how to obtain the JXME source code, skip ahead to the section on Using the Chat Demonstration. Tooling Up Building the JXME demonstrations requires some finesse on your part. You'll need to become a member of the JXME project, then obtain the source code, then build and run the examples. If this sounds like too much work, go back to the preceding section and run the binaries instead. The following instructions are an expanded version of the build instructions at the JXME web site. If you're already adept with Apache's Ant build utility, the CVS source-code control system, and J2ME, you may want to follow the more concise instructions instead of stepping through the rest of this article. Joining the JXME project is simple enough. First, you'll need to register to be a member of Project JXTA. Browse to the JXME home page, and in the left column find the Developer Resources folder. Click on the Join Project JXTA link. You'll need to choose a user name and to supply an email address and your real name. Once you're logged in as a member of Project JXTA, navigate back to the JXME home page. You will see a link for Join This Project on the right side of the page. Click on this link and follow the directions. Most likely you will want to join as a Contributor. To obtain and build the source code, you'll need the following tools: Getting the Source Code
Linux and other Unix-like operating systems come with a
When WinCvs first starts, it will ask you for a :pserver:<username>@cvs.jxta.org:/cvs
Just below the CVSROOT box, change Authentication to
"password" file on the cvs server. Next, log in to the CVS server. In WinCvs, choose Admin > Login. Type your password. If everything goes well, a message will tell you CVS exited normally. Create a directory on your local disk to hold the JXME source. Then, in WinCvs, choose Create > Checkout Module. Specify the module name to be jxme/midp, and in Local folder to checkout to supply the name of your local directory. WinCvs will chug along for a while as it downloads the source tree. When it's finished, choose Admin > Logout, then quit WinCvs. Building and Running the Source Code Before you can build and run the chat demonstration using Ant, you need to define
some environment variables. The chat build script uses
Once all the environment variables are defined, open a command-line window and navigate to jxme\midp. Install the custom Ant build action: ant tools You have to do this step only once. Next build the JXME projects: ant Now move to jxme\midp\demo\chat. Use Ant to run the chat example: ant run Using the Chat Demonstration When the emulator window first pops up, it shows the name of a single MIDlet, JxtaMidpChat. Launch the MIDlet. You'll see a mostly empty screen. From the menu choose the Configuration command. You can accept most of the default settings, but you'll probably want to specify an Identity. This is a name that will be used to identify you to other chat users. When you're finished with the settings, select OK. You will see a screen titled Buddy List. This screen lists groups. Just select the default, IP2PGRP, and then choose the Chat command to return to the main screen. Then choose Connect from the menu. The chat client will connect to the relay server and return to the main screen. You are now connected to the JXTA network and can exchange messages with people on all types of JXTA clients. Thanks to the relay server, your emulator is part of the JXTA network. Digging Deeper into P2P If the P2P bug has bitten you, there are several other aspects of JXTA you might want to think about:
Summary
JXME introduces you to a whole new world of possibilities. P2P
networking offers a decentralized network fabric. JXTA furnishes an XML-based,
platform-independent set of protocols that enable P2P networking, and
the JXME project brings JXTA functionality into the MIDP world. This article
also described how to run the JXME chat application, either by downloading binaries
or by downloading and building the source code. Back To Top | ||||||||||
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
|
| ||||||||||||