public final class ServiceUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static void |
checkIsServiceBound(java.lang.Object service,
java.lang.Class<?> type,
java.lang.String message)
Check the given service== null and in case throws an exception.
|
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.
|
public static <T> T getService(BundleContext context,
java.lang.Class<T> clazz,
long timeout)
throws java.lang.InterruptedException
T - expected service classclazz - the service class of the DeclarativeService interfacetimeout - the number of milliseconds to wait for the ServiceTracker to find the servicecontext - the contextjava.lang.InterruptedException - a InterruptedExceptionpublic static <T> T getService(BundleContext context,
java.lang.Class<T> clazz)
throws java.lang.InterruptedException
T - expected service classclazz - the clazzcontext - the contextjava.lang.InterruptedException - the interrupted exceptionpublic static <T> T getService(java.lang.Class<T> clazz,
long timeout)
throws java.lang.InterruptedException
T - expected service classclazz - the clazztimeout - the number of milliseconds to wait for the ServiceTracker to find the servicejava.lang.InterruptedException - the interrupted exceptionpublic static <T> T getService(java.lang.Class<T> clazz)
throws java.lang.InterruptedException
T - expected service classclazz - the clazzjava.lang.InterruptedException - the interrupted exceptionpublic static ServiceReference[] getServiceReferences(BundleContext context,
java.lang.String clazz)
clazz - the class name of the DeclarativeService interfacecontext - the contextpublic static ServiceReference[] getServiceReferences(java.lang.String clazz)
clazz - the class name of the DeclarativeService interfacepublic static ServiceReference[] getServiceReferences(java.lang.Class<?> clazz)
clazz - the class of the DeclarativeService interfacepublic static <T> T getService(BundleContext context,
ServiceReference reference,
java.lang.Class<T> clazz)
T - expected service classcontext - the contextreference - the referenceclazz - expected service classpublic static <T> T getService(ServiceReference reference,
java.lang.Class<T> clazz)
T - expected service classreference - the referenceclazz - expected service classpublic static void checkIsServiceBound(java.lang.Object service,
java.lang.Class<?> type,
java.lang.String message)
service - the servicetype - the typemessage - the messageServiceNotBoundException - the service not bound exception