JXTA

net.jxta.impl.resolver
Class ResolverServiceImpl

java.lang.Object
  extended by net.jxta.impl.resolver.ResolverServiceImpl
All Implemented Interfaces:
Module, GenericResolver, ResolverService, Service

public class ResolverServiceImpl
extends Object
implements ResolverService

Implements the ResolverService using the standard JXTA Endpoint Resolver Protocol (ERP).

See Also:
ResolverService, JXTA Protocols Specification : Endpoint Resolver Protocol

Nested Class Summary
(package private) static class ResolverServiceImpl.CurrentCredential
          Encapsulates current Membership Service credential.
(package private)  class ResolverServiceImpl.FailureListener
          Listener to find bad destinations and clean srdi tables for them.
 
Field Summary
(package private)  ResolverServiceImpl.CurrentCredential currentCredential
          The current Membership service default credential.
static String inQueNameShort
          Resolver response endpoint postfix
(package private)  net.jxta.impl.resolver.ResolverServiceImpl.CredentialListener membershipCredListener
           
static String outQueNameShort
          Resolver query endpoint postfix
static String srdiQueNameShort
          Resolver srdi endpoint postfix
 
Fields inherited from interface net.jxta.resolver.ResolverService
OK, Repropagate
 
Fields inherited from interface net.jxta.platform.Module
START_AGAIN_PROGRESS, START_AGAIN_STALLED, START_DISABLED, START_OK
 
Constructor Summary
ResolverServiceImpl()
           
 
Method Summary
 QueryHandler getHandler(String name)
          given a name returns the query handler associated with it
 ModuleImplAdvertisement getImplAdvertisement()
          Returns the advertisement for this service.
 ResolverService getInterface()
          Service objects are not manipulated directly to protect usage of the service.
 SrdiHandler getSrdiHandler(String name)
          given a name returns the srdi handler associated with it
 void init(PeerGroup group, ID assignedID, Advertisement impl)
          Initialize the module, passing it its peer group and advertisement.
 QueryHandler registerHandler(String name, QueryHandler handler)
          Registers a given QueryHandler, returns the previous handler registered under this name.
 SrdiHandler registerSrdiHandler(String name, SrdiHandler handler)
          Registers a given SrdiHandler, returns the previous handler registered under this name.
 void sendQuery(String destPeer, ResolverQueryMsg query)
          Sends a resolver query.
 void sendResponse(String destPeer, ResolverResponseMsg response)
          Send a resolver response.
 void sendSrdi(String destPeer, ResolverSrdiMsg srdi)
          Send an SRDI message.
 int startApp(String[] arg)
          Complete any remaining initialization of the module.
 void stopApp()
          Stop a module.
 QueryHandler unregisterHandler(String name)
          Unregisters a given QueryHandler, returns the previous handler registered under this name.
 SrdiHandler unregisterSrdiHandler(String name)
          Unregisters a given SrdiHandler, returns the previous handler registered under this name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outQueNameShort

public static final String outQueNameShort
Resolver query endpoint postfix

See Also:
Constant Field Values

inQueNameShort

public static final String inQueNameShort
Resolver response endpoint postfix

See Also:
Constant Field Values

srdiQueNameShort

public static final String srdiQueNameShort
Resolver srdi endpoint postfix

See Also:
Constant Field Values

currentCredential

ResolverServiceImpl.CurrentCredential currentCredential
The current Membership service default credential.


membershipCredListener

final net.jxta.impl.resolver.ResolverServiceImpl.CredentialListener membershipCredListener
Constructor Detail

ResolverServiceImpl

public ResolverServiceImpl()
Method Detail

init

public void init(PeerGroup group,
                 ID assignedID,
                 Advertisement impl)
Initialize the module, passing it its peer group and advertisement.

Note: when subclassing one of the existing PeerGroup implementations (which implement Module), it may not be recommended to overload the init method. See the documentation of the PeerGroup class being subclassed.

Specified by:
init in interface Module
Parameters:
group - The PeerGroup from which this Module can obtain services. If this module is a Service, this is also the PeerGroup of which this module is a service.
assignedID - Identity of Module within group. modules can use it as a the root of their namespace to create names that are unique within the group but predictable by the same module on another peer. This is normally the ModuleClassID which is also the name under which the module is known by other modules. For a group it is the PeerGroupID itself. The parameters of a service, in the Peer configuration, are indexed by the assignedID of that service, and a Service must publish its run-time parameters in the Peer Advertisement under its assigned ID.
impl - The implementation advertisement for this Module. It is permissible to pass null if no implementation advertisement is available. This may happen if the implementation was selected by explicit class name rather than by following an implementation advertisement. Modules are not required to support that style of loading, but if they do, then their documentation should mention it.

startApp

public int startApp(String[] arg)
Complete any remaining initialization of the module. The module should be fully functional after startApp() is completed. That is also the opportunity to supply arbitrary arguments (mostly to applications).

If this module is a PeerGroup service, it may be invoked several times depending on its return value.

Specified by:
startApp in interface Module
Parameters:
arg - An array of Strings forming the parameters for this Module.
Returns:
int A status indication which may be one of Module.START_OK, Module.START_AGAIN_PROGRESS, Module.START_AGAIN_STALLED, which indicates partial or complete success, or any other value (negative values are recommended for future compatibility), which indicates failure.

stopApp

public void stopApp()
Stop a module. This may be called any time after init() completes and should not assume that startApp() has been called or completed.

The Module cannot be forced to comply, but in the future we might be able to deny it access to anything after some timeout.

Specified by:
stopApp in interface Module

getInterface

public ResolverService getInterface()
Service objects are not manipulated directly to protect usage of the service. A Service interface is returned to access the service methods.

Specified by:
getInterface in interface Service
Returns:
Service public interface of the service

getImplAdvertisement

public ModuleImplAdvertisement getImplAdvertisement()
Returns the advertisement for this service.

Specified by:
getImplAdvertisement in interface Service
Returns:
Advertisement the advertisement. This is always a ModuleImplAdvertisement.

registerHandler

public QueryHandler registerHandler(String name,
                                    QueryHandler handler)
Registers a given QueryHandler, returns the previous handler registered under this name.

Specified by:
registerHandler in interface ResolverService
Parameters:
name - The name under which this handler is to be registered.
handler - The handler.
Returns:
The previous handler registered under this name.

unregisterHandler

public QueryHandler unregisterHandler(String name)
Unregisters a given QueryHandler, returns the previous handler registered under this name.

Specified by:
unregisterHandler in interface ResolverService
Parameters:
name - The name of the handler to unregister.
Returns:
The previous handler registered under this name.

getHandler

public QueryHandler getHandler(String name)
given a name returns the query handler associated with it

Parameters:
name - the handler to lookup
Returns:
returns the query handler

registerSrdiHandler

public SrdiHandler registerSrdiHandler(String name,
                                       SrdiHandler handler)
Registers a given SrdiHandler, returns the previous handler registered under this name.

Specified by:
registerSrdiHandler in interface ResolverService
Parameters:
name - The name under which this handler is to be registered.
handler - The handler.
Returns:
The previous handler registered under this name.

unregisterSrdiHandler

public SrdiHandler unregisterSrdiHandler(String name)
Unregisters a given SrdiHandler, returns the previous handler registered under this name.

Specified by:
unregisterSrdiHandler in interface ResolverService
Parameters:
name - The name of the handler to unregister.
Returns:
The previous handler registered under this name

getSrdiHandler

public SrdiHandler getSrdiHandler(String name)
given a name returns the srdi handler associated with it

Parameters:
name - the handler to lookup
Returns:
returns the SRDI handler

sendQuery

public void sendQuery(String destPeer,
                      ResolverQueryMsg query)
Sends a resolver query. If destPeer is null the message is propagated.

Specified by:
sendQuery in interface ResolverService
Parameters:
destPeer - The destination peer of the query or null if the query is to be propagated.
query - The query to match.

sendResponse

public void sendResponse(String destPeer,
                         ResolverResponseMsg response)
Send a resolver response. If destPeer is null then the response is propagated. Propagated responses are generally announcements and not responses to active queries.

Specified by:
sendResponse in interface ResolverService
Parameters:
destPeer - The destination peer of the response or null if the response is to be propagated.
response - The response to be sent.

sendSrdi

public void sendSrdi(String destPeer,
                     ResolverSrdiMsg srdi)
Send an SRDI message.

If destPeer is null the message is walked.

Specified by:
sendSrdi in interface ResolverService
Parameters:
destPeer - is the destination of the SRDI message.
srdi - is the SRDI message to be sent.

JXSE