Project JXTA

net.jxta.impl.resolver
Class ResolverService

java.lang.Object
  |
  +--net.jxta.impl.resolver.ResolverService

public class ResolverService
extends java.lang.Object
implements net.jxta.resolver.Resolver, EndpointHandler

ResolverService Service provides a generic mechanism for jxta Services to send "Queries", and receive "Responses". It removes the burden for registered handlers in deal with : - Setting message tags, to ensure uniqueness of tags and ensures that messages are sent to correct address, and group - Authentication, and Verification of credentials - drop rogue messages ResolverService Service does not proccess the queries, nor does it not compose reponses. Handling of queries, and composition of responses are left up to the registered handlers. Services that wish to handle queries, and generate reponses must implement QueryHandler Message Format : A Query message name uri token id query Note: queryid is unique to the originating node only, it can be utilized to match queries to responses. A Response Message name uri token id response Note: queryid is unique to the originating node only, it can be utilized to match queries to responses

Since:
JXTA 1.0
See Also:
,

Field Summary
 java.lang.String inQueName
           
 java.lang.String outQueName
           
protected  java.util.Vector rendezvous
           
 
Constructor Summary
ResolverService()
           
 
Method Summary
 void demux(MessageImpl message)
          This method will be called by the endpoint to handle messages of this type
 net.jxta.document.Advertisement getAdvertisement()
          Returns the advertisement for that service.
 net.jxta.peergroup.PeerGroup getGroup()
           
 net.jxta.resolver.QueryHandler getHandler(java.lang.String name)
          gets the handler registered under the given name.
 net.jxta.service.Service getInterface()
          Service objects are not manipulated directly to protect usage of the service.
 void init(net.jxta.peergroup.PeerGroup g, net.jxta.document.Advertisement sadv)
          init is called by the group running this instance
 net.jxta.protocol.ResolverResponseMsg processQuery(net.jxta.protocol.ResolverQueryMsg query)
          Process the message and respond
 void pushResponse(net.jxta.protocol.ResolverResponseMsg resp)
          push Response back to the handler
 net.jxta.resolver.QueryHandler registerHandler(java.lang.String name, net.jxta.resolver.QueryHandler handler)
          Registers the given ResolveHandler.
 void ResolverService()
          Default constructor
 void sendQuery(java.lang.String rdvPeer, net.jxta.protocol.ResolverQueryMsg query)
          try getting a response for out query
 void sendResponse(java.lang.String destPeer, net.jxta.protocol.ResolverResponseMsg response)
          Send a response to a peer.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outQueName

public java.lang.String outQueName

inQueName

public java.lang.String inQueName

rendezvous

protected java.util.Vector rendezvous
Constructor Detail

ResolverService

public ResolverService()
Method Detail

ResolverService

public void ResolverService()
Default constructor

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

registerHandler

public net.jxta.resolver.QueryHandler registerHandler(java.lang.String name,
                                                      net.jxta.resolver.QueryHandler handler)
Registers the given ResolveHandler.
Specified by:
registerHandler in interface net.jxta.resolver.Resolver
Parameters:
name - The name under which this handler is known.
handler - The handler.
Returns:
The previous handler registered under this name

getHandler

public net.jxta.resolver.QueryHandler getHandler(java.lang.String name)
gets the handler registered under the given name.
Specified by:
getHandler in interface net.jxta.resolver.Resolver
Parameters:
name - Handler name
Returns:
ResolveHandler

sendQuery

public void sendQuery(java.lang.String rdvPeer,
                      net.jxta.protocol.ResolverQueryMsg query)
try getting a response for out query
Parameters:
address -  
query -  
Throws:
java.lang.RuntimeException -  

getGroup

public net.jxta.peergroup.PeerGroup getGroup()

demux

public void demux(MessageImpl message)
This method will be called by the endpoint to handle messages of this type
Specified by:
demux in interface EndpointHandler
Parameters:
message -  

processQuery

public net.jxta.protocol.ResolverResponseMsg processQuery(net.jxta.protocol.ResolverQueryMsg query)
                                                   throws net.jxta.exception.NoResponseException,
                                                          net.jxta.exception.ResendQueryException,
                                                          net.jxta.exception.DiscardQueryException,
                                                          java.io.IOException
Process the message and respond
Parameters:
query -  
Returns:
ResolverResponseMsg response
Throws:
net.jxta.exception.NoResponseException -  

pushResponse

public void pushResponse(net.jxta.protocol.ResolverResponseMsg resp)
push Response back to the handler
Parameters:
query -  
Returns:
ResolverResponseMsg response
Throws:
net.jxta.exception.NoResponseException -  

sendResponse

public void sendResponse(java.lang.String destPeer,
                         net.jxta.protocol.ResolverResponseMsg response)
Send a response to a peer. This is used by resolver services that are handling query/response in an asynchronous way, which is the case of Rendezvous peers.
Parameters:
destPeer - is the destination of the response
response - is the response to be sent

init

public void init(net.jxta.peergroup.PeerGroup g,
                 net.jxta.document.Advertisement sadv)
          throws net.jxta.exception.PeerGroupException
init is called by the group running this instance
Parameters:
g -  
Throws:
net.jxta.exception.PeerGroupException -  

Project JXTA