Class ServiceUtils

java.lang.Object
org.apache.felix.http.base.internal.util.ServiceUtils

public abstract class ServiceUtils extends Object
Utility methods to get/unget services, ignoring exceptions that might occur on bundle stop/update
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    safeGetService(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref)
    Get the service
    static <T> T
    safeGetServiceObjects(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref)
    Get the service using ServiceObjects
    static <T> void
    safeUngetService(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref)
    Unget the service
    static <T> void
    safeUngetServiceObjects(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref, T service)
    Unget the service using ServiceObjects

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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
      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
    • safeGetServiceObjects

      public static <T> T safeGetServiceObjects(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref)
      Get the service using ServiceObjects
      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 using ServiceObjects