O'Reilly logo

JXTA in a Nutshell by Li Gong, Bernard Traversat, Scott Oaks

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Integration with Other Network Services

As we said at the start of this chapter, JXTA does not require that network services use pipes or other JXTA facilities in order to be invoked; you can create network services that advertise themselves to JXTA peergroups but are invoked via another technique. We’ll conclude this chapter with a brief discussion of how this can be accomplished.

We’ll center our discussion around an RMI-based network service. The specific details in our discussion will apply to RMI-based services only, but the general technique will be applicable to other types of network services.

The general technique is this: the service must publish a standard module service advertisement within a JXTA peergroup. The service advertisement must contain information so that JXTA peers can contact it; this information is stored in the param tag of the service advertisement. JXTA peers that discover the advertisement extract the special information from the param tag and contact the service using that information.

RMI clients contact RMI servers via a specialized class known as a stub. An RMI service that wants to advertise itself in a JXTA peergroup must encode its stub into the service advertisement. Here’s how a service can achieve this:

import java.rmi.*; import java.rmi.server.*; import java.io.*; import net.jxta.peergroup.PeerGroup; import net.jxta.peergroup.PeerGroupFactory; import net.jxta.exception.PeerGroupException; import net.jxta.document.Advertisement; import ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required