SMILA 1.0 API documentation

org.eclipse.smila.utils.service
Class ServiceUtils

java.lang.Object
  extended by org.eclipse.smila.utils.service.ServiceUtils

public final class ServiceUtils
extends java.lang.Object

The Class ServiceHelper.


Method Summary
static
<T> T
getService(BundleContext context, java.lang.Class<T> clazz)
          Gets the service with default wait delay.
static
<T> T
getService(BundleContext context, java.lang.Class<T> clazz, long timeout)
          Uses a ServiceTracker to get the given DeclarativeService.
static
<T> T
getService(BundleContext context, ServiceReference reference, java.lang.Class<T> clazz)
          resolve a service reference.
static
<T> T
getService(java.lang.Class<T> clazz)
          Gets the service with default wait delay using the BundleContext of UtilsActivator.
static
<T> T
getService(java.lang.Class<T> clazz, long timeout)
          Gets the service with the given wait delay using the BundleContext of UtilsActivator.
static
<T> T
getService(ServiceReference reference, java.lang.Class<T> clazz)
          resolve a service reference.
static ServiceReference[] getServiceReferences(BundleContext context, java.lang.String clazz)
          Uses a ServiceTracker to get the service references.
static ServiceReference[] getServiceReferences(java.lang.Class<?> clazz)
          Uses a ServiceTracker to get the service references.
static ServiceReference[] getServiceReferences(java.lang.String clazz)
          Uses a ServiceTracker to get the service references.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getService

public static <T> T getService(BundleContext context,
                               java.lang.Class<T> clazz,
                               long timeout)
                    throws java.lang.InterruptedException
Uses a ServiceTracker to get the given DeclarativeService.

Type Parameters:
T - expected service class
Parameters:
clazz - the service class of the DeclarativeService interface
timeout - the number of milliseconds to wait for the ServiceTracker to find the service
context - the context
Returns:
the DeclarativeService.
Throws:
java.lang.InterruptedException - a InterruptedException

getService

public static <T> T getService(BundleContext context,
                               java.lang.Class<T> clazz)
                    throws java.lang.InterruptedException
Gets the service with default wait delay.

Type Parameters:
T - expected service class
Parameters:
clazz - the clazz
context - the context
Returns:
the service
Throws:
java.lang.InterruptedException - the interrupted exception

getService

public static <T> T getService(java.lang.Class<T> clazz,
                               long timeout)
                    throws java.lang.InterruptedException
Gets the service with the given wait delay using the BundleContext of UtilsActivator.

Type Parameters:
T - expected service class
Parameters:
clazz - the clazz
timeout - the number of milliseconds to wait for the ServiceTracker to find the service
Returns:
the service
Throws:
java.lang.InterruptedException - the interrupted exception

getService

public static <T> T getService(java.lang.Class<T> clazz)
                    throws java.lang.InterruptedException
Gets the service with default wait delay using the BundleContext of UtilsActivator.

Type Parameters:
T - expected service class
Parameters:
clazz - the clazz
Returns:
the service
Throws:
java.lang.InterruptedException - the interrupted exception

getServiceReferences

public static ServiceReference[] getServiceReferences(BundleContext context,
                                                      java.lang.String clazz)
Uses a ServiceTracker to get the service references.

Parameters:
clazz - the class name of the DeclarativeService interface
context - the context
Returns:
the service references

getServiceReferences

public static ServiceReference[] getServiceReferences(java.lang.String clazz)
Uses a ServiceTracker to get the service references.

Parameters:
clazz - the class name of the DeclarativeService interface
Returns:
the service references

getServiceReferences

public static ServiceReference[] getServiceReferences(java.lang.Class<?> clazz)
Uses a ServiceTracker to get the service references.

Parameters:
clazz - the class of the DeclarativeService interface
Returns:
the service references

getService

public static <T> T getService(BundleContext context,
                               ServiceReference reference,
                               java.lang.Class<T> clazz)
resolve a service reference.

Type Parameters:
T - expected service class
Parameters:
context - the context
reference - the reference
clazz - expected service class
Returns:
the service instance.

getService

public static <T> T getService(ServiceReference reference,
                               java.lang.Class<T> clazz)
resolve a service reference.

Type Parameters:
T - expected service class
Parameters:
reference - the reference
clazz - expected service class
Returns:
the service instance.

SMILA 1.0 API documentation