Advertisements

Let’s look now at some JXTA advertisements. Advertisements are central to JXTA; you discover JXTA peers and their resources by looking for advertisements, and you provide your own services by publishing advertisements. Therefore, working with advertisements and the documents they contain is the next step we must take in learning how to develop JXTA applications.

Advertisements are represented by the abstract Advertisement class (net.jxta.document.Advertisement). Each advertisement has a unique type, which is returned by the getAdvertisementType( ) method. The JXTA API defines the following core advertisement types (each of which is an abstract class in the net.jxta.protocol package):

  • PeerAdvertisement

  • PeerGroupAdvertisement

  • PipeAdvertisement

  • PeerInfoAdvertisement

  • EndpointAdvertisement

  • ModuleClassAdvertisement , ModuleSpecAdvertisement, and ModuleImplAdver-tisement (module-related advertisements)

  • RdvAdvertisement

  • TransportAdvertisement

Each advertisement object holds an object that implements the Document interface (net.jxta.document.Document) and represents the advertisement. An advertisement is typically represented as an XML document, and the JXTA protocol specification relies heavily on XML advertisements. The getDocument( ) method of the Advertisement class returns a representation of the advertisement in different formats based on its MimeMediaType argument. Typical MIME types are “text/xml” or “text/plain” (which, in fact, are the only ...

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.