Service Activator Toolkit
Version 1.1.0 (20081206)

org.eclipse.soda.sat.core.util
Class ServiceReferenceUtility

java.lang.Object
  extended by org.eclipse.soda.sat.core.util.ServiceReferenceUtility

public final class ServiceReferenceUtility
extends Object

The ServiceReferenceUtility class is a utility that simplifies working with ServiceReference objects.

Note: This is a singleton class, accessible only via the static method getInstance(). For example:

 ServiceReferenceUtility utility = ServiceReferenceUtility.getInstance();
 String[] names = utility.getServiceNames(reference);
 

See Also:
ServiceReference

Method Summary
 Comparator createServiceRankingComparator()
          Create a Comparator for sorting an array or collection of ServiceReference objects by service rank (highest to lowest) and then by service id (lowest to highest).
static ServiceReferenceUtility getInstance()
          Public getter for the ServiceReferenceUtility singleton instance.
 long getServiceId(ServiceReference reference)
          Gets the Constants.SERVICE_ID property from the specified ServiceReference objects.
 long[] getServiceIds(ServiceReference[] references)
          Gets the Constants.SERVICE_ID properties from an array of ServiceReference objects.
 List getServiceNames(ServiceReference reference)
          Answers an array of service names available from the specified ServiceReference.
 List getServiceNames(ServiceReference[] references)
          Gets the service names from an array of ServiceReference objects.
 boolean isServiceInstanceOf(ServiceReference reference, String name)
          Answers true if the ServiceReference is an instance of the service name.
 ServiceReference select(ServiceReference[] references)
          Select an appropriate ServiceReference from an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ServiceReferenceUtility getInstance()
Public getter for the ServiceReferenceUtility singleton instance.

Returns:
The ServiceReferenceUtility singleton instance.

createServiceRankingComparator

public Comparator createServiceRankingComparator()
Create a Comparator for sorting an array or collection of ServiceReference objects by service rank (highest to lowest) and then by service id (lowest to highest).

Returns:
Comparator

getServiceId

public long getServiceId(ServiceReference reference)
Gets the Constants.SERVICE_ID property from the specified ServiceReference objects.

Parameters:
reference - A ServiceReference.
Returns:
The Constants.SERVICE_ID property value.

getServiceIds

public long[] getServiceIds(ServiceReference[] references)
Gets the Constants.SERVICE_ID properties from an array of ServiceReference objects.

Parameters:
references - An array of ServiceReference objects.
Returns:
An array of Constants.SERVICE_ID property values.

getServiceNames

public List getServiceNames(ServiceReference reference)
Answers an array of service names available from the specified ServiceReference.

Parameters:
reference - The ServiceReference to be queried.
Returns:
A list of fully qualifed type names.

getServiceNames

public List getServiceNames(ServiceReference[] references)
Gets the service names from an array of ServiceReference objects.

Parameters:
references - An array of ServiceReference objects.
Returns:
An list of service names.

isServiceInstanceOf

public boolean isServiceInstanceOf(ServiceReference reference,
                                   String name)
Answers true if the ServiceReference is an instance of the service name.

Parameters:
reference - The ServiceReference to be queried.
name - A fully qualified type name of a service.
Returns:
If the ServiceReference represents the service name return true, otherwise false.

select

public ServiceReference select(ServiceReference[] references)
Select an appropriate ServiceReference from an array. The criteria for selection is as follows:

Parameters:
references - An array of ServiceReference objects from which to select.
Returns:
The matching ServiceReference or null.

Service Activator Toolkit
Version 1.1.0 (20081206)