org.jafer.registry.uddi
Class ServiceLocator

java.lang.Object
  extended by org.jafer.registry.uddi.ServiceLocator
All Implemented Interfaces:
ServiceLocator

public class ServiceLocator
extends java.lang.Object
implements ServiceLocator

The service locator is responsible for finding providers and services in the registry. Usernames and passwords are not required to search the registry.


Field Summary
protected static java.util.logging.Logger logger
          Stores a reference to the Logger
private  int maxReturned
          Stores a reference to the maximum objects to return on any find call, defaulted to 0 for no limit
private  org.uddi4j.client.UDDIProxy registryConnection
          Stores a reference to the UDDI4J Proxy manager that communicates with the registry
private  TModelManager tModelManager
          Stores a reference to the TModelManager that loads and initialises all the required TModels.
 
Constructor Summary
ServiceLocator(org.uddi4j.client.UDDIProxy registryConnection, TModelManager tModelManager)
          Constructor for the service locator.
 
Method Summary
private  org.uddi4j.util.CategoryBag buildCategoryBag(java.util.List categories)
          Builds a category bag containg all the categories to be used by the search
private  java.util.Vector buildNames(java.lang.String name)
          Builds the vector of search names required for searching by name
private  org.uddi4j.util.FindQualifiers buildQualifiers(boolean useLogicalOR)
          Builds the find qualifiers for the search
private  org.uddi4j.util.TModelBag buildTModelBag(java.util.List protocols)
          Builds a tmodel bag containg all the protocols tmodels to be used by the search
 java.util.List findService(Category category)
          Finds the services that have the supplied category attached
 java.util.List findService(Protocol protocol)
          Finds the services that support the supplied protocol
 java.util.List findService(ServiceProviderInfo serviceProviderInfo)
          Finds the services that match the supplied service provider info.
 java.util.List findService(ServiceProviderInfo serviceProviderInfo, java.lang.String name, java.util.List categories, java.util.List protocols, boolean useLogicalOR)
          This method allows services to be located by using all the possible search combinations.
 java.util.List findService(java.lang.String name)
          Finds the service that match the supplied name.
 java.util.List findServiceProvider(Category category)
          Finds the service providers that have the supplied category attached
 java.util.List findServiceProvider(Protocol protocol)
          Finds the service providers that have services supporting the supplied protocol
 java.util.List findServiceProvider(java.lang.String name)
          Finds the service providers that match the supplied name.
 java.util.List findServiceProvider(java.lang.String name, java.util.List categories, java.util.List protocols, boolean useLogicalOR)
          This method allows service providers to be located by using all the possible search combinations.
 Service getService(ServiceInfo serviceInfo)
          Retrieves the full service object for the supplied service info.
 Service getService(java.lang.String id)
          Gets the service from its unique ID
 ServiceProvider getServiceProvider(Service service)
          Gets the service provider that owns the service
 ServiceProvider getServiceProvider(ServiceProviderInfo providerInfo)
          Retrieves the full service provider object for the supplied service provider info.
 ServiceProvider getServiceProvider(java.lang.String id)
          Gets the service provider from its unique ID
 Service refreshService(Service service)
          Returns the latest version of the service found.
 ServiceProvider refreshServiceProvider(ServiceProvider provider)
          Returns the latest version of the service provider found.
 void setMaxReturned(int maxReturned)
          Allows the caller to overload the default number of instances returned from a find call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tModelManager

private TModelManager tModelManager
Stores a reference to the TModelManager that loads and initialises all the required TModels. It is expected to have already been initialised when it is used by this class


maxReturned

private int maxReturned
Stores a reference to the maximum objects to return on any find call, defaulted to 0 for no limit


registryConnection

private org.uddi4j.client.UDDIProxy registryConnection
Stores a reference to the UDDI4J Proxy manager that communicates with the registry


logger

protected static java.util.logging.Logger logger
Stores a reference to the Logger

Constructor Detail

ServiceLocator

public ServiceLocator(org.uddi4j.client.UDDIProxy registryConnection,
                      TModelManager tModelManager)
Constructor for the service locator.

Parameters:
registryConnection - The connection to the UDDI registry
tModelManager - The tmodel manager for the registry being accessed by this manager
Method Detail

setMaxReturned

public void setMaxReturned(int maxReturned)
Allows the caller to overload the default number of instances returned from a find call. Default value is set to 0 so no limits applied

Specified by:
setMaxReturned in interface ServiceLocator
Parameters:
maxReturned - The maximum number of instances to return

findServiceProvider

public java.util.List findServiceProvider(java.lang.String name)
                                   throws RegistryException
Finds the service providers that match the supplied name. The name can contain one or more % wildcard characters.

Specified by:
findServiceProvider in interface ServiceLocator
Parameters:
name - The name of the provider to search for.
Returns:
A list of ServiceProviderInfo objects for each service provider found
Throws:
RegistryException

findServiceProvider

public java.util.List findServiceProvider(Category category)
                                   throws RegistryException
Finds the service providers that have the supplied category attached

Specified by:
findServiceProvider in interface ServiceLocator
Parameters:
category - The category and value to search by
Returns:
A list of ServiceProviderInfo objects for each service provider found
Throws:
RegistryException

findServiceProvider

public java.util.List findServiceProvider(Protocol protocol)
                                   throws RegistryException
Finds the service providers that have services supporting the supplied protocol

Specified by:
findServiceProvider in interface ServiceLocator
Parameters:
protocol - The protocol to search by
Returns:
A list of ServiceProviderInfo objects for each service provider found
Throws:
RegistryException

findServiceProvider

public java.util.List findServiceProvider(java.lang.String name,
                                          java.util.List categories,
                                          java.util.List protocols,
                                          boolean useLogicalOR)
                                   throws RegistryException
This method allows service providers to be located by using all the possible search combinations. Name, categories and protocols are all optional to ignore pass:
The name can contain one or more % wildcard characters. If useLogicalOR is set to false then all the categories and protocols must be attached to the service provider for it to be returned rather than just one of the categories or protocols.

Specified by:
findServiceProvider in interface ServiceLocator
Parameters:
name - The name of the provider to search for.
categories - A list of categories and values to search by
protocols - A list of protocols s to search by
useLogicalOR - true to use OR operator, false to use AND operator
Returns:
A list of ServiceProviderInfo objects for each service provider found
Throws:
RegistryException

getServiceProvider

public ServiceProvider getServiceProvider(Service service)
                                   throws RegistryException
Gets the service provider that owns the service

Specified by:
getServiceProvider in interface ServiceLocator
Parameters:
service - The service to search by
Returns:
The service provider that owns the service or NULL if not found
Throws:
RegistryException

getServiceProvider

public ServiceProvider getServiceProvider(ServiceProviderInfo providerInfo)
                                   throws RegistryException
Retrieves the full service provider object for the supplied service provider info.

Specified by:
getServiceProvider in interface ServiceLocator
Parameters:
providerInfo - The service provider info identifying the service provider to retrieve
Returns:
A ServiceProvider object for the supplied service provider info
Throws:
RegistryException

refreshServiceProvider

public ServiceProvider refreshServiceProvider(ServiceProvider provider)
                                       throws RegistryException
Returns the latest version of the service provider found. Any changes to the supplied service provider will be ignored and a fresh copy will be retrieved from the registry.

Note: Any service objects retrieved of the orignal provider will contain out dates information after this call and should no longer be used. Updating the old provider or services will cause the old information to replace the current in the registry

Specified by:
refreshServiceProvider in interface ServiceLocator
Parameters:
provider - The provider to refresh
Returns:
The refreshed service provider object
Throws:
RegistryException

findService

public java.util.List findService(ServiceProviderInfo serviceProviderInfo)
                           throws RegistryException
Finds the services that match the supplied service provider info.

Specified by:
findService in interface ServiceLocator
Parameters:
serviceProviderInfo - perform the search over the services on this service provider
Returns:
A list of ServiceInfo objects for each service found
Throws:
RegistryException

findService

public java.util.List findService(java.lang.String name)
                           throws RegistryException
Finds the service that match the supplied name. The name can contain one or more % wildcard characters.

Specified by:
findService in interface ServiceLocator
Parameters:
name - The name of the service to search for.
Returns:
A list of ServiceInfo objects for each service found
Throws:
RegistryException

findService

public java.util.List findService(Category category)
                           throws RegistryException
Finds the services that have the supplied category attached

Specified by:
findService in interface ServiceLocator
Parameters:
category - The category and value to search by
Returns:
A list of ServiceInfo objects for each service found
Throws:
RegistryException

findService

public java.util.List findService(Protocol protocol)
                           throws RegistryException
Finds the services that support the supplied protocol

Specified by:
findService in interface ServiceLocator
Parameters:
protocol - The protocol to search by
Returns:
A list of ServiceInfo objects for each service found
Throws:
RegistryException

findService

public java.util.List findService(ServiceProviderInfo serviceProviderInfo,
                                  java.lang.String name,
                                  java.util.List categories,
                                  java.util.List protocols,
                                  boolean useLogicalOR)
                           throws RegistryException
This method allows services to be located by using all the possible search combinations. ServiceProviderInfo, Name, categories and protocols are all optional to ignore pass:
The name can contain one or more % wildcard characters. If useLogicalOR is set to false then all the categories and protocols must be attached to the service for it to be returned rather than just one of the categories or protocols.

Specified by:
findService in interface ServiceLocator
Parameters:
serviceProviderInfo - perform the search over the services on this provider
name - The name of the service to search for.
categories - A list of categories and values to search by
protocols - A list of protocols s to search by
useLogicalOR - true to use OR operator, false to use AND operator
Returns:
A list of ServiceInfo objects for each service found
Throws:
RegistryException

getService

public Service getService(ServiceInfo serviceInfo)
                   throws RegistryException
Retrieves the full service object for the supplied service info.

Specified by:
getService in interface ServiceLocator
Parameters:
serviceInfo - The service info identifying the service to retrieve
Returns:
A Service object for the supplied service info
Throws:
RegistryException

refreshService

public Service refreshService(Service service)
                       throws RegistryException
Returns the latest version of the service found. Any changes to the supplied service will be ignored and a fresh copy will be retrieved from the registry.

Specified by:
refreshService in interface ServiceLocator
Parameters:
service - The service to refresh
Returns:
The refreshed service object
Throws:
RegistryException

getServiceProvider

public ServiceProvider getServiceProvider(java.lang.String id)
                                   throws RegistryException
Gets the service provider from its unique ID

Specified by:
getServiceProvider in interface ServiceLocator
Parameters:
id - The ID of the service provider
Returns:
The service provider for the ID or NULL if not found
Throws:
RegistryException

getService

public Service getService(java.lang.String id)
                   throws RegistryException
Gets the service from its unique ID

Specified by:
getService in interface ServiceLocator
Parameters:
id - The ID of the service
Returns:
The service for the ID or NULL if not found
Throws:
RegistryException

buildNames

private java.util.Vector buildNames(java.lang.String name)
Builds the vector of search names required for searching by name

Parameters:
name - The name of the service to search for.
Returns:
A vector of Name objects

buildCategoryBag

private org.uddi4j.util.CategoryBag buildCategoryBag(java.util.List categories)
Builds a category bag containg all the categories to be used by the search

Parameters:
categories - A list of categories and values to search by
Returns:
category bag containg all the categories

buildTModelBag

private org.uddi4j.util.TModelBag buildTModelBag(java.util.List protocols)
                                          throws RegistryException
Builds a tmodel bag containg all the protocols tmodels to be used by the search

Parameters:
protocols - A list of protocols to search by
Returns:
tmodel bag containg all the protocols tmodels
Throws:
RegistryException

buildQualifiers

private org.uddi4j.util.FindQualifiers buildQualifiers(boolean useLogicalOR)
Builds the find qualifiers for the search

Parameters:
useLogicalOR - true to use OR operator, false to use AND operator
Returns:
the findqualifers for performing logical or / logical and