|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--gov.sns.tools.services.ServiceDirectory
ServiceDirectory is a local point of access for registering and looking up services on a network. It wraps the standard Rendezvous mechanism to provide a simple way to register and lookup services by using a Java interface as a service name. XML-RPC is the communication protocol used for messaging. Both Rendezvous and XML-RPC are accepted protocols implemented in multiple languages.
| Field Summary | |
protected java.util.Map |
listenerMap
Table mapping ServiceListener to the corresponding rendezvous service listener |
| Constructor Summary | |
ServiceDirectory()
ServiceDirectory constructor. |
|
| Method Summary | |
void |
addServiceListener(java.lang.Class protocol,
ServiceListener listener)
Add a listener for addition and removal of service providers. |
void |
addServiceListener(java.lang.String type,
ServiceListener listener)
Add a listener for addition and removal of service providers. |
static ServiceDirectory |
defaultDirectory()
Get the default ServiceDirectory instance. |
void |
dispose()
Shutdown rendezvous and the web server and dispose of all resources. |
ServiceRef[] |
findServicesWithType(java.lang.Class protocol,
long timeout)
Convenience method for making a request to find service providers of a specific service type and waiting a specified amount of time to find those services. |
ServiceRef[] |
findServicesWithType(java.lang.String serviceType,
long timeout)
Convenience method for making a request to find service providers of a specific service type and waiting a specified amount of time to find those services. |
protected static gov.sns.tools.services.ClientHandler |
getClientHandler(java.lang.Object proxy)
Convenience method for getting the ClientHandler for the given proxy |
protected static java.lang.String |
getDefaultType(java.lang.Class protocol)
Form a valid type based on the specified protocol by replacing the protocol's name with a valid name in which "." is replaced by "_". |
static java.lang.String |
getHost(java.lang.Object proxy)
Get the remote host for the service |
static java.lang.Class |
getProtocol(java.lang.Object proxy)
Get the protocol of the remote proxy |
java.lang.Object |
getProxy(java.lang.Class protocol,
ServiceRef serviceRef)
Get a proxy to the service with the given service reference and protocol. |
static java.lang.String |
getServiceName(java.lang.Object proxy)
Get the service name for the remote service |
ServiceRef |
lookupService(java.lang.String type,
java.lang.String name)
Lookup the service given the fully qualified service type and the fully qualified service name |
ServiceRef |
lookupService(java.lang.String type,
java.lang.String name,
int timeout)
Lookup the service given the fully qualified service type and the fully qualified service name and block until a match is found or the specified timeout has expired. |
ServiceRef |
registerService(java.lang.Class protocol,
java.lang.String name,
java.lang.Object provider)
Register a local service provider. |
ServiceRef |
registerService(java.lang.String serviceType,
java.lang.String name,
java.lang.Object provider)
Register a local service provider. |
ServiceRef |
registerService(java.lang.String serviceType,
java.lang.String serviceName,
java.lang.Object provider,
java.util.Hashtable properties)
Register a local service provider. |
void |
removeServiceListener(ServiceListener listener)
Remove a listener of service availability events. |
boolean |
unregisterService(ServiceRef serviceRef)
Unregister a local service. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.util.Map listenerMap
| Constructor Detail |
public ServiceDirectory()
| Method Detail |
public static ServiceDirectory defaultDirectory()
public void dispose()
public ServiceRef registerService(java.lang.Class protocol,
java.lang.String name,
java.lang.Object provider)
protocol - The protocol identifying the service type.name - The unique name of the service provider.provider - The provider which handles the service requests.
public ServiceRef registerService(java.lang.String serviceType,
java.lang.String name,
java.lang.Object provider)
serviceType - The type of service being registered.name - The unique name of the service provider.provider - The provider which handles the service requests.
public ServiceRef registerService(java.lang.String serviceType,
java.lang.String serviceName,
java.lang.Object provider,
java.util.Hashtable properties)
serviceType - The type of service being registered.serviceName - The unique name of the service provider.provider - The provider which handles the service requests.properties - Properties.
public boolean unregisterService(ServiceRef serviceRef)
serviceRef - The service reference whose service should be shutdown.
public java.lang.Object getProxy(java.lang.Class protocol,
ServiceRef serviceRef)
protocol - The protocol implemented by the service.serviceRef - The service reference.
public ServiceRef lookupService(java.lang.String type,
java.lang.String name)
type - The fully qualified service typename - The fully qualified service name
public ServiceRef lookupService(java.lang.String type,
java.lang.String name,
int timeout)
type - The fully qualified service typename - The fully qualified service nametimeout - The timeout in milliseconds to block until a match is found
public ServiceRef[] findServicesWithType(java.lang.Class protocol,
long timeout)
protocol - The protocol identifying the service type for which to find providers.timeout - Time to block in milliseconds while waiting for services to be discovered.
addServiceListener(java.lang.Class, gov.sns.tools.services.ServiceListener)
public ServiceRef[] findServicesWithType(java.lang.String serviceType,
long timeout)
serviceType - The type of service to find.timeout - Time to block in milliseconds while waiting for services to be discovered.
addServiceListener(java.lang.Class, gov.sns.tools.services.ServiceListener)
public void addServiceListener(java.lang.Class protocol,
ServiceListener listener)
protocol - The protocol identifying the service type.listener - The receiver of service availability events.
public void addServiceListener(java.lang.String type,
ServiceListener listener)
type - The type of service provided.listener - The receiver of service availability events.public void removeServiceListener(ServiceListener listener)
listener - The listener of service availability events.protected static java.lang.String getDefaultType(java.lang.Class protocol)
protocol - The protocol for which to get a valid type
public static java.lang.String getHost(java.lang.Object proxy)
proxy - the proxy to the service at the remote host
public static java.lang.String getServiceName(java.lang.Object proxy)
proxy - the proxy to the remote service
public static java.lang.Class getProtocol(java.lang.Object proxy)
proxy - the proxy to the remote service
protected static gov.sns.tools.services.ClientHandler getClientHandler(java.lang.Object proxy)
proxy - the proxy for which we seek its client handler
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||