Project JXTA

net.jxta.impl.peer
Class PeerInfoService

java.lang.Object
  |
  +--net.jxta.impl.peer.PeerInfoService

public class PeerInfoService
extends java.lang.Object
implements net.jxta.peer.PeerInfo, net.jxta.resolver.QueryHandler

Peer Info provides a mechanism to obtain information about peers.

Since:
1.0

Constructor Summary
PeerInfoService()
           
 
Method Summary
 void flushAdvertisements(java.lang.String id)
          flush cached advertisements.
 net.jxta.document.Advertisement getAdvertisement()
          Returns the advertisement for that service.
 net.jxta.peergroup.PeerGroup getGroup()
          Returns the group to which this service is attached.
 net.jxta.service.Service getInterface()
          Service objects are not manipulated directly to protect usage of the service.
 java.util.Enumeration getLocalPeerInfo(java.lang.String peer)
          Get PeerInfo from local cache.
 net.jxta.protocol.PeerInfoAdvertisement getPeerInfo()
          Retrieve Peer Information Advertisement of localhost
 void getRemotePeerInfo(java.lang.String peer)
          Get PeerInfo from a remote peer.
 void init(net.jxta.peergroup.PeerGroup group, net.jxta.document.Advertisement sadv)
          init is called by PeerGroup to init the Service
 net.jxta.protocol.ResolverResponseMsg processQuery(net.jxta.protocol.ResolverQueryMsg query)
          Handler API method
 void pushResponse(net.jxta.protocol.ResolverResponseMsg response)
          deal with incoming responses
 void registerService(net.jxta.protocol.ServiceAdvertisement advertisement)
          Register a Service in the Peer Advertisement service adversement describes a specific service that is running on the peer (i.e.
 int startApp(java.lang.String[] arg)
          Supply arguments and starts this service if it hadn't started by itself.
 void stopApp()
          Ask this service to stop.
 void unRegisterService(net.jxta.protocol.ServiceAdvertisement advertisement)
          unRegisters a prevously registered service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeerInfoService

public PeerInfoService()
Method Detail

startApp

public int startApp(java.lang.String[] arg)
Supply arguments and starts this service if it hadn't started by itself. Currently this service starts by itself and does not expect arguments.
Parameters:
arg - A table of strings arguments.
Returns:
int status indication.

stopApp

public void stopApp()
Ask this service to stop. This request is currently ignored.

getInterface

public net.jxta.service.Service getInterface()
Service objects are not manipulated directly to protect usage of the service. A Service interface is returned to access the service methods.
Returns:
Service public interface of the service
Since:
JXTA 1.0

getAdvertisement

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

init

public void init(net.jxta.peergroup.PeerGroup group,
                 net.jxta.document.Advertisement sadv)
          throws net.jxta.exception.PeerGroupException
init is called by PeerGroup to init the Service
Parameters:
pg - Peer Group
Throws:
net.jxta.exception.PeerGroupException - throw any exception thrown during obtaining Service

getPeerInfo

public net.jxta.protocol.PeerInfoAdvertisement getPeerInfo()
Retrieve Peer Information Advertisement of localhost
Specified by:
getPeerInfo in interface net.jxta.peer.PeerInfo
Returns:
PeerInfoAdvertisement

registerService

public void registerService(net.jxta.protocol.ServiceAdvertisement advertisement)
                     throws java.io.IOException
Register a Service in the Peer Advertisement service adversement describes a specific service that is running on the peer (i.e. LDAP, etc)
Specified by:
registerService in interface net.jxta.peer.PeerInfo
Parameters:
advertisement - service advertisement to be registered
Throws:
java.io.IOException - if registeration fails

unRegisterService

public void unRegisterService(net.jxta.protocol.ServiceAdvertisement advertisement)
                       throws java.io.IOException
unRegisters a prevously registered service
Specified by:
unRegisterService in interface net.jxta.peer.PeerInfo
Parameters:
advertisement - service advertisement to be unregistered
Throws:
java.io.IOException - if the un-registeration fails

getRemotePeerInfo

public void getRemotePeerInfo(java.lang.String peer)
Get PeerInfo from a remote peer.
Specified by:
getRemotePeerInfo in interface net.jxta.peer.PeerInfo
Parameters:
peer - Address of a peer, or portal to connect to, if address is null

getLocalPeerInfo

public java.util.Enumeration getLocalPeerInfo(java.lang.String peer)
                                       throws java.io.IOException
Get PeerInfo from local cache.
Specified by:
getLocalPeerInfo in interface net.jxta.peer.PeerInfo
Parameters:
peer - Address of a peer. Can be null in which case locally cached PeerInfoAdvertisements of all peers are returned
Returns:
An Enumeration of locally cached advertisements for this peer

getGroup

public net.jxta.peergroup.PeerGroup getGroup()
Returns the group to which this service is attached.
Returns:
PeerGroup the group

processQuery

public net.jxta.protocol.ResolverResponseMsg processQuery(net.jxta.protocol.ResolverQueryMsg query)
                                                   throws net.jxta.exception.NoResponseException
Handler API method
Specified by:
processQuery in interface net.jxta.resolver.QueryHandler
Parameters:
query - ResolverQueryMsg
Returns:
ResolverResponseMsg response
Throws:
net.jxta.exception.NoResponseException - if no Responses were received

pushResponse

public void pushResponse(net.jxta.protocol.ResolverResponseMsg response)
deal with incoming responses
Specified by:
pushResponse in interface net.jxta.resolver.QueryHandler
Parameters:
response -  

flushAdvertisements

public void flushAdvertisements(java.lang.String id)
                         throws java.io.IOException
flush cached advertisements.
Specified by:
flushAdvertisements in interface net.jxta.peer.PeerInfo
Parameters:
id - peerId of peer whose locally cached adv is to be deleted. If null, cached advs of all peers are deleted.

Project JXTA