|
Project JXTA | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The jxta DiscoveryService Service provides asynchronous mechanism in jxta for discovering Peer Advertisements, Group Advertisements, and general jxta Advertisements (pipe, service, etc.). The scope of discovery can controlled by specifying name and attribute pair, and a threshold. The threshold is an upper limit the requesting peer specifies for responding peers not to exceed. Each jxta Peer Group has an instance of a DiscoveryService Service the scope of the discovery is limited to the group. for example
A peer in the soccer group invokes the soccer group's DiscoveryService Service to discover pipe advertisements in the group, and is interested in a maximum of 10 Advertisements from each peer:
discovery.getRemoteAdvertisements(null, discovery.ADV, null, null,10);
discovery.publish(adv,discovery.ADV);
parent=soccerGroup.getParent(); discovery= parent.getDiscovery() discovery.publish(adv,discovery.ADV);
<?xml version="1.0" standalone='yes'?> <DiscoveryQuery> <type>int</type> <threshold>int</threshold> <peeradv>peeradv</peeradv> <attribute>attribute</attribute> <value>attribute</value> </DiscoveryQuery>
Service
,
Resolver
,
DiscoveryQueryMsg
,
DiscoveryResponseMsg
,
ResolverQueryMsg
,
ResolverResponseMsg
Field Summary | |
static int |
ADV
DOC type |
static long |
DEFAULT_EXPIRATION
Default expiration time for advertisements. |
static long |
DEFAULT_LIFETIME
|
static int |
GROUP
Group type |
static int |
PEER
Peer type |
Method Summary | |
void |
addDiscoveryListener(DiscoveryListener listener)
Add a discovery listener |
void |
flushAdvertisements(java.lang.String id,
int type)
flush stored Documents. |
java.util.Enumeration |
getLocalAdvertisements(int type,
java.lang.String attribute,
java.lang.String value)
Retrieve Stored Peer, Group, and General Advertisements |
int |
getRemoteAdvertisements(java.lang.String peerid,
int type,
java.lang.String attribute,
java.lang.String value,
int threshold)
This method discovers PeerAdvertisements, GroupAdvertisements and jxta Advertisements. |
void |
publish(Advertisement advertisement,
int type)
Publish an advertisement |
void |
publish(Advertisement adv,
int type,
long lifetime,
long lifetimeForOthers)
Publish an advertisement that will expire after a certain time. |
void |
remotePublish(Advertisement adv,
int type)
Remote Publish an advertisement |
void |
remotePublish(Advertisement adv,
int type,
long lifetime)
Remote Publish an advertisement |
boolean |
removeDiscoveryListener(DiscoveryListener listener)
remove a discovery listener |
Methods inherited from interface net.jxta.service.Service |
getAdvertisement,
getInterface |
Methods inherited from interface net.jxta.platform.Application |
init,
startApp,
stopApp |
Field Detail |
public static final int PEER
public static final int GROUP
public static final int ADV
public static final long DEFAULT_LIFETIME
public static final long DEFAULT_EXPIRATION
Method Detail |
public int getRemoteAdvertisements(java.lang.String peerid, int type, java.lang.String attribute, java.lang.String value, int threshold)
attribute
- attribute name to narrow disocvery tovalue
- value of attribute to narrow disocvery tothreshold
- the upper limit of responses from one peerpeerid
- id of a peer, or "rendezvous" to connect to, if
address is nulltype
- PEER, GROUP, ADVpublic java.util.Enumeration getLocalAdvertisements(int type, java.lang.String attribute, java.lang.String value) throws java.io.IOException
type
- PEER, GROUP, or ADVattribute
- attribute name to narrow the response tovalue
- value of the named attribute to narrow the response topublic void publish(Advertisement advertisement, int type) throws java.io.IOException
advertisement
- publish an adverisement within this grouptype
- PEER, GROUP, ADVpublic void publish(Advertisement adv, int type, long lifetime, long lifetimeForOthers) throws java.io.IOException
advertisement
- the advertisementtype
- PEER, GROUP, ADVlifetime
- the amount of time this advertisement will live
in my cachelifetimeForOthers
- the amount of time this advertisement
will live in other people's caches.public void remotePublish(Advertisement adv, int type)
advertisement
- publish an adverisement within this grouptype
- PEER, GROUP, ADVpublic void remotePublish(Advertisement adv, int type, long lifetime)
advertisement
- publish an adverisement within this grouptype
- PEER, GROUP, ADVlifetime
- the amount of time to advise other nodes to hold
this advertisement in their caches.public void flushAdvertisements(java.lang.String id, int type) throws java.io.IOException
id
- Document ID, Peer ID, or PeerGroup IDtype
- PEER, GROUP, ADVpublic void addDiscoveryListener(DiscoveryListener listener)
DiscoveryListener
- listener to receive discovery eventspublic boolean removeDiscoveryListener(DiscoveryListener listener)
DiscoveryListener
- listener to remove
|
Project JXTA | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |