Project JXTA

net.jxta.impl.discovery
Class DiscoveryInterface

java.lang.Object
  |
  +--net.jxta.impl.discovery.DiscoveryInterface

public class DiscoveryInterface
extends java.lang.Object
implements net.jxta.discovery.Discovery

DiscoveryInterface provides a pure interface object that permits interaction with the actual DiscoveryService implementation without giving access to the real object.


Fields inherited from interface net.jxta.discovery.Discovery
ADV, DEFAULT_EXPIRATION, DEFAULT_LIFETIME, GROUP, PEER
 
Constructor Summary
DiscoveryInterface(DiscoveryService theRealThing)
          Only authorized constructor
 
Method Summary
 void addDiscoveryListener(net.jxta.discovery.DiscoveryListener listener)
          Add a discovery listener
 void flushAdvertisements(java.lang.String id, int type)
          flush cached peer Advertisements.
 net.jxta.document.Advertisement getAdvertisement()
          Returns the advertisment for that service.
 net.jxta.service.Service getInterface()
          returns an interface object that permits to use this service without having access to the real object.
 java.util.Enumeration getLocalAdvertisements(int type, java.lang.String attribute, java.lang.String value)
          Retrieve Stored Advertisements
 int getRemoteAdvertisements(java.lang.String peer, int type, java.lang.String attribute, java.lang.String value, int threshold)
          Discover peers within a region set by the endpoint
 void init(net.jxta.peergroup.PeerGroup pg, net.jxta.document.Advertisement a)
          Initialize the application FIXME: This is meaningless for the interface object; it is there only to satisfy the requirements of the interface that we implement.
 void publish(net.jxta.document.Advertisement adv, int type)
          Publish an advertisement same as above, provided as a convenience
 void publish(net.jxta.document.Advertisement adv, int type, long lifetime, long lifetimeForOthers)
          Publish an advertisement that will expire after a certain time.
 void remotePublish(net.jxta.document.Advertisement adv, int type)
           
 void remotePublish(net.jxta.document.Advertisement adv, int type, long lifetime)
          Remote Publish an advertisement
 boolean removeDiscoveryListener(net.jxta.discovery.DiscoveryListener listener)
          remove a discovery listener
 int startApp(java.lang.String[] arg)
          This is here for temporary class hierarchy reasons.
 void stopApp()
          This is here for temporary class hierarchy reasons.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiscoveryInterface

public DiscoveryInterface(DiscoveryService theRealThing)
Only authorized constructor
Method Detail

getInterface

public net.jxta.service.Service getInterface()
returns an interface object that permits to use this service without having access to the real object. Since THIS is already such an object, it returns itself. FIXME: it is kind of absurd to have this method part of the interface but we do not want to define two levels of Service interface just for that.
Returns:
Resolver An interface object that implements this service and nothing more.

getAdvertisement

public net.jxta.document.Advertisement getAdvertisement()
Returns the advertisment for that service.
Returns:
Advertisement the advertisement.
Since:
JXTA 1.0

init

public void init(net.jxta.peergroup.PeerGroup pg,
                 net.jxta.document.Advertisement a)
Initialize the application FIXME: This is meaningless for the interface object; it is there only to satisfy the requirements of the interface that we implement. Ultimately, the API should define two levels of interfaces: one for the real service implementation and one for the interface object. Right now it feels a bit heavy to so that since the only different between the two would be init() and may-be getName().
Parameters:
group - PeerGroup this application is started from
Since:
JXTA 1.0

startApp

public int startApp(java.lang.String[] arg)
This is here for temporary class hierarchy reasons. it is ALWAYS ignored. By definition, the interface object protects the real object's start/stop methods from being called
Parameters:
arg - A table of strings arguments.
Returns:
int status indication.

stopApp

public void stopApp()
This is here for temporary class hierarchy reasons. it is ALWAYS ignored. By definition, the interface object protects the real object's start/stop methods from being called This request is currently ignored.

getRemoteAdvertisements

public int getRemoteAdvertisements(java.lang.String peer,
                                   int type,
                                   java.lang.String attribute,
                                   java.lang.String value,
                                   int threshold)
Discover peers within a region set by the endpoint
Specified by:
getRemoteAdvertisements in interface net.jxta.discovery.Discovery
Parameters:
address - Address of a peer, or portal to connect to, if address is null then getPeerAdv "discover" in the region of the group
See Also:
net.jxta.endpoint.Address

getLocalAdvertisements

public java.util.Enumeration getLocalAdvertisements(int type,
                                                    java.lang.String attribute,
                                                    java.lang.String value)
                                             throws java.io.IOException
Retrieve Stored Advertisements
Specified by:
getLocalAdvertisements in interface net.jxta.discovery.Discovery
Returns:
Enumeration of stored advertisements/structured documents
Since:
JXTA 1.0

flushAdvertisements

public void flushAdvertisements(java.lang.String id,
                                int type)
                         throws java.io.IOException
flush cached peer Advertisements.
Specified by:
flushAdvertisements in interface net.jxta.discovery.Discovery

publish

public void publish(net.jxta.document.Advertisement adv,
                    int type)
             throws java.io.IOException
Publish an advertisement same as above, provided as a convenience
Specified by:
publish in interface net.jxta.discovery.Discovery
Parameters:
doc - StructuredDocument to publish

publish

public void publish(net.jxta.document.Advertisement adv,
                    int type,
                    long lifetime,
                    long lifetimeForOthers)
             throws java.io.IOException
Publish an advertisement that will expire after a certain time. A node that finds this advertisement will hold it for about lifetimeForOthers milliseconds, while the peer that has originally published the advertisement will republish it about every lifetiemForOthers milliseconds, until lifetime expires.
Specified by:
publish in interface net.jxta.discovery.Discovery
Parameters:
advertisement - the advertisement
type - PEER, GROUP, ADV
lifetime - the amount of time this advertisement will live in my cache
lifetimeForOthers - the amount of time this advertisement will live in other people's caches.
Throws:
java.io.IOException - - If an I/O error occurs

remotePublish

public void remotePublish(net.jxta.document.Advertisement adv,
                          int type)
Specified by:
remotePublish in interface net.jxta.discovery.Discovery

remotePublish

public void remotePublish(net.jxta.document.Advertisement adv,
                          int type,
                          long lifetime)
Remote Publish an advertisement
Specified by:
remotePublish in interface net.jxta.discovery.Discovery
Parameters:
advertisement - publish an adverisement within this group
type - PEER, GROUP, ADV
lifetime - the amount of time to advise other nodes to hold this advertisement in their caches.
Since:
JXTA 1.0

addDiscoveryListener

public void addDiscoveryListener(net.jxta.discovery.DiscoveryListener listener)
Add a discovery listener
Specified by:
addDiscoveryListener in interface net.jxta.discovery.Discovery
Parameters:
DiscoveryListener - listener to receive discovery events

removeDiscoveryListener

public boolean removeDiscoveryListener(net.jxta.discovery.DiscoveryListener listener)
remove a discovery listener
Specified by:
removeDiscoveryListener in interface net.jxta.discovery.Discovery
Parameters:
DiscoveryListener - listener to remove
Returns:
true if the argument was a component of this vector; false otherwise

Project JXTA