Name
DiscoveryService
Synopsis
This interface represents the core JXTA
discovery service. All peergroups have an implementation of the
discovery service, which is used to locate advertisements within the
peergroup. The discovery service of a particular peergroup is
retrieved via the getDiscoveryService( ) method of
the PeerGroup class.
Applications keep a persistent cache of
previously discovered advertisements. In the core Java bindings, the
persistent cache is held in the filesystem (in the
cm directory) and survives between runs of the
application; in other implementations, the cache may exist only while
the device is on. Applications look for advertisements within the
cache by using the getLocalAdvertisements( )
method. The cache is emptied by the flushAdvertisements( ) method.
Applications look for uncached
advertisements by using the getRemoteAdvertisements( ) method. This sends out the discovery message using the
PDP and sets up a background daemon thread that listens for
responses. The background thread places those responses in the local
cache where they may be retrieved by the
getLocalAdvertisements( ) method. Alternately, a
discovery event listener may be registered with the discovery service
by calling the addDiscoveryListener( ) method, in
which case the listener will be called whenever a new advertisement
is discovered.
The publish( ) method
places a new advertisement in the local cache; the
remotePublish( ) method provides a new advertisement available ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access