com.j_spaces.core.client
Class LookupFinder

java.lang.Object
  extended by com.j_spaces.core.client.LookupFinder
All Implemented Interfaces:
com.j_spaces.core.Constants.Client

public class LookupFinder
extends Object
implements com.j_spaces.core.Constants.Client

LookupFinder is a generalized concept of the SpaceFinder utility. It simplifies the process of service lookup and acquiring a proxy of this service. The lookup performed on three criterions: service name, service class and service attributes. Any one of the above criterion can be null.


Nested Class Summary
static class LookupFinder.LookupEntriesComparator
           
 
Field Summary
static long DEFAULT_TIMEOUT
          Default service lookup timeout Default value is 5 seconds
 
Fields inherited from interface com.j_spaces.core.Constants.Client
CLIENT_RETRY_CONNECTION_DEFAULT, CLIENT_RETRY_CONNECTION_PROP, FULL_CLIENT_RETRY_CONNECTION_PROP, FULL_NUMBER_OF_IMPLICIT_INDEXES_PROP, NUMBER_OF_IMPLICIT_INDEXES_DEFAULT, NUMBER_OF_IMPLICIT_INDEXES_PROP
 
Constructor Summary
LookupFinder()
           
 
Method Summary
static Object find(Class[] classes, Entry[] srvAttr, String lookupHost, long timeout, Properties customProps)
          Finds specified service according to service classes and service attributes.
static Object find(String serviceName, Class[] classes, Entry[] serviceAttributes, String lookupHost, String groups, long timeout)
          Finds specified server using all the criterion: service name, service classes and service attributes.
static Object find(String serviceName, Class[] classes, Entry[] serviceAttributes, String lookupHost, String groups, long timeout, long timeoutInterval, Properties customProps)
          Finds specified server using all the criterions: service name, service classes and service attributes.
static Object find(String serviceName, Class[] classes, Entry[] serviceAttributes, String lookupHost, String groups, long timeout, Properties customProps)
          Finds specified server using all the criterions: service name, service classes and service attributes.
static Object find(String serviceName, Class srvClass, String lookupHost, long timeout, Properties customProps)
          Finds specified service according to service name and service class only.
static boolean waitForLookupService(String[] groups, LookupLocator[] locators, long timeout, long intervalTimeout)
          Creates (or reuses) the lookup service and waits for at least one LUS to be discovered.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TIMEOUT

public static final long DEFAULT_TIMEOUT
Default service lookup timeout Default value is 5 seconds

See Also:
Constant Field Values
Constructor Detail

LookupFinder

public LookupFinder()
Method Detail

find

public static Object find(String serviceName,
                          Class[] classes,
                          Entry[] serviceAttributes,
                          String lookupHost,
                          String groups,
                          long timeout,
                          Properties customProps)
                   throws FinderException
Finds specified server using all the criterions: service name, service classes and service attributes.

Parameters:
serviceName - Service name. Can be null.
classes - Array of service class. Can be null
serviceAttributes - Array of service attributes. Can be null
lookupHost - A hostname of the computer running the Jini Lookup service where the search to be done If null then the search is issued on any available Jini Lookup service using multicast protocol.
groups - Comma separated string of groups that the service belongs to
timeout - lookup timeout
customProps - The custom properties object which might contain overwrites to the configuration. In our case, it can include the unicast list of hosts which we will lookup upon using unicast discovery.
Returns:
Object reference to service proxy
Throws:
FinderException - Failed to find desired serviceName.

find

public static Object find(String serviceName,
                          Class[] classes,
                          Entry[] serviceAttributes,
                          String lookupHost,
                          String groups,
                          long timeout,
                          long timeoutInterval,
                          Properties customProps)
                   throws FinderException
Finds specified server using all the criterions: service name, service classes and service attributes.

Parameters:
serviceName - Service name. Can be null.
classes - Array of service class. Can be null
serviceAttributes - Array of service attributes. Can be null
lookupHost - A hostname of the computer running the Jini Lookup service where the search to be done If null then the search is issued on any available Jini Lookup service using multicast protocol.
groups - Comma separated string of groups that the service belongs to
timeout - lookup timeout
timeoutInterval - The interval we use in order to poll the SDM for lookup items
customProps - The custom properties object which might contain overwrites to the configuration. In our case, it can include the unicast list of hosts which we will lookup upon using unicast discovery.
Returns:
Object reference to service proxy
Throws:
FinderException - Failed to find desired serviceName.

waitForLookupService

public static boolean waitForLookupService(String[] groups,
                                           LookupLocator[] locators,
                                           long timeout,
                                           long intervalTimeout)
                                    throws Exception
Creates (or reuses) the lookup service and waits for at least one LUS to be discovered. Returns true if the LUS was discovered within the given timeout.

Parameters:
groups - The groups to use to find the LUS
locators - The locators to use to find the LUS
timeout - The time to wait in order to find a LUS
intervalTimeout - The interval (in millis) at which the finder polls for LUS
Returns:
true if a LUS was found. false otherwise.
Throws:
Exception

find

public static Object find(String serviceName,
                          Class[] classes,
                          Entry[] serviceAttributes,
                          String lookupHost,
                          String groups,
                          long timeout)
                   throws FinderException
Finds specified server using all the criterion: service name, service classes and service attributes.

Parameters:
serviceName - Service name. Can be null.
classes - Array of service class. Can be null
serviceAttributes - Array of service attributes. Can be null
lookupHost - A hostname of the computer running the Jini Lookup service where the search to be done If null then the search is issued on any available Jini Lookup service using multicast protocol.
groups - Comma separated string of groups that the service belongs to
timeout - lookup timeout
Returns:
Object reference to service proxy
Throws:
FinderException - Failed to find desired serviceName.

find

public static Object find(String serviceName,
                          Class srvClass,
                          String lookupHost,
                          long timeout,
                          Properties customProps)
                   throws FinderException
Finds specified service according to service name and service class only.

Parameters:
serviceName - Service name. Can be null.
srvClass - Service classes. Can be null
lookupHost - A hostname of the computer running the Jini Lookup service where the search to be done If null then the search is issued on any available Jini Lookup service
timeout - lookup timeout
customProps - The custom properties object which might contain overwrites to the configuration. In our case, it might include the unicast list of hosts which we will lookup upon using unicast discovery.
Returns:
Object reference to service proxy
Throws:
FinderException - Failed to find desired serviceName.

find

public static Object find(Class[] classes,
                          Entry[] srvAttr,
                          String lookupHost,
                          long timeout,
                          Properties customProps)
                   throws FinderException
Finds specified service according to service classes and service attributes.

Parameters:
classes - Array of service classes. Can be null
srvAttr - Array of service attributes. Can be null
lookupHost - A hostname of the computer running the Jini Lookup service where the search to be done If null then the search is issued on any available Jini Lookup service
timeout - lookup timeout
customProps - The custom properties object which might contain overwrites to the configuration. In our case, it can include the unicast list of hosts which we will lookup upon using unicast discovery.
Returns:
Object reference to service proxy
Throws:
FinderException - Failed to find desired serviceName.