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

Pipe Discovery

In this section, we’ll look at the implementation of the HungryPeer. One new technique is that the HungryPeer must construct the message that it sends to the RestoPeer. With the new technique, the HungryPeer discovers the published pipe advertisement of a RestoPeer; in our last example, the RestoPeer received the pipe advertisement in the HungyPeer’s auction message.

Here’s the implementation of the HunrgyPeer that discovers the pipe:

import java.io.*; import java.util.Enumeration; import java.util.Vector; import net.jxta.peergroup.PeerGroup; import net.jxta.peergroup.PeerGroupFactory; import net.jxta.exception.PeerGroupException; import net.jxta.document.AdvertisementFactory; import net.jxta.document.Advertisement; import net.jxta.document.StructuredDocument; import net.jxta.document.Element; import net.jxta.document.StructuredDocumentFactory; import net.jxta.document.MimeMediaType; import net.jxta.discovery.DiscoveryService; import net.jxta.pipe.PipeService; import net.jxta.pipe.InputPipe; import net.jxta.pipe.PipeID; import net.jxta.pipe.OutputPipe; import net.jxta.endpoint.Message; import net.jxta.protocol.PipeAdvertisement; import net.jxta.protocol.PeerGroupAdvertisement; import net.jxta.id.IDFactory; // The HungryPeer joins the RestoNet peergroup and searches for RestoPeers. // The HungryPeer then establishes a pipe connection to all the RestoPeers // that it discovered. It sends auction requests for French fries to // RestoPeers and then waits for auction ...

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