At a specification level, JXTA defines a number of protocols that enable P2P computing. At another level, the JXTA community has developed language bindings; these bindings implement the protocols and allow developers to write JXTA applications. Embedded within these bindings are several core JXTA services that provide needed functions for JXTA applications. Neither the language bindings nor the core service implementations provided by the JXTA community are strictly necessary in order to develop JXTA applications: as long as the application correctly implements the necessary protocols, it can use any language, network transport, and service implementation to do so. Nonetheless, we expect most initial JXTA applications to follow the Java language bindings presented throughout this book and to use the core services implementations provided by the JXTA community.
Think in terms of other protocol specifications. Today, most computer networks run on the Internet Protocol (IP) specification. Other network protocols, like the Transmission Control Protocol (TCP) and Uniform Datagram Protocol (UDP), are layered on top of IP. Still other protocols, such as the HyperText Transfer Protocol (HTTP), are layered on top of those protocols. Yet for the most part, developers of network applications and services have no idea how the underlying protocols work. Developers create a TCP connection to another server by opening a socket with the BSD socket library, the WinSock socket library, the Java Socket class, or some other API layer. Some intrepid developers may use TCP sockets to send HTTP protocol messages, but most will use an HTTP protocol binding, such as the Java URL-related classes. Still fewer developers will open raw IP sockets and deal with the network at that level.
JXTA is a network protocol that is layered on top of other network protocols. In its Java language bindings, it is layered on both TCP and HTTP, but it can be layered equally as well over emerging network standards, such as Bluetooth. You could certainly open TCP sockets and send JXTA protocol messages over those sockets, but it is far easier to use the JXTA language bindings to hide the details of the protocol.
There are similar layers within the language bindings as well. The primary mechanism that JXTA peers use to communicate with each other is the JXTA pipe, and there are protocols specifying how JXTA pipes work. The protocols depend on JXTA endpoints, which are essentially network connections (for which there are other JXTA protocols). However, the JXTA pipe classes shield the developer from needing to know about the JXTA pipe protocols, the JXTA endpoint protocols, and the JXTA endpoint classes.
Our intent in this book is to give an overview of the underlying protocols and features of JXTA and to focus on the high-level Java language API bindings that use those protocols. These are the bindings that you’ll need to implement most types of JXTA applications and services. If you’re interested in moving JXTA to other networks or developing other language bindings, you’ll need to consult the JXTA specifications that are online at spec.jxta.org and are reprinted in the reference section of this book.
In Chapter 2, we use a standard JXTA demo application—the JXTA Shell—to step through and understand the key features of the JXTA platform. These include:
- Peers
Peers are the basic unit of JXTA. They are any type of networked device, although in JXTA we often make the distinction between a peer that provides a service and one that uses a service. The former is referred to as a service while the latter is referred to as an application. However, all services are applications: a peer that provides a service from which you can order French fries is itself a consumer of a service that provides peer discovery. Generally, peers can be both producers and consumers of services.
- Peergroups
Peers self-organize into peergroups. A peer must belong to a peergroup before it can communicate with other peers (and it can communicate only with peers that have joined the same peergroup). A peer can join multiple peergroups.
- Pipes
Pipes are the basic tool that JXTA peers use to communicate with each other. They are somewhat analogous to UDP sockets: they send or receive chunked pieces of data.
- Advertisements
Advertisements are special XML documents that announce the presence of JXTA resources. A JXTA resource can be just about anything used by a peer: other JXTA peers, peergroups, pipes, and services (such as an auctioning service) provided by JXTA peers.
- Discovery
Discovery is the basic process by which peers locate advertisements and, consequently, locate resources that they can use.
Get JXTA in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.