Class ServiceUtils
java.lang.Object
org.apache.felix.http.base.internal.util.ServiceUtils
Utility methods to get/unget services, ignoring exceptions that might occur
on bundle stop/update
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TsafeGetService(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref) Get the servicestatic <T> TsafeGetServiceObjects(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref) Get the service usingServiceObjectsstatic <T> voidsafeUngetService(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref) Unget the servicestatic <T> voidsafeUngetServiceObjects(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref, T service) Unget the service usingServiceObjects
-
Constructor Details
-
ServiceUtils
public ServiceUtils()
-
-
Method Details
-
safeGetService
public static <T> T safeGetService(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref) Get the service- Type Parameters:
T- The service type- Parameters:
ctx- The bundle contextref- The service reference- Returns:
- The service or
null
-
safeUngetService
public static <T> void safeUngetService(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref) Unget the service- Type Parameters:
T- The service type- Parameters:
ctx- The bundle contextref- The service reference
-
safeGetServiceObjects
public static <T> T safeGetServiceObjects(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref) Get the service usingServiceObjects- Type Parameters:
T- The service type- Parameters:
ctx- The bundle contextref- The service reference- Returns:
- The service or
null
-
safeUngetServiceObjects
public static <T> void safeUngetServiceObjects(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref, T service) Unget the service usingServiceObjects- Type Parameters:
T- The service type- Parameters:
ctx- The bundle contextref- The service referenceservice- The service
-