Package org.apache.felix.http.base.internal.util

# 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
`ServiceUtils()`

## 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

Type Parameters:
  `T` - The service type
Parameters:
  `ctx` - The bundle context
  `ref` - 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 context
  `ref` - The service reference

### safeGetServiceObjects

public static <T> T safeGetServiceObjects(org.osgi.framework.BundleContext ctx, org.osgi.framework.ServiceReference<T> ref)
Get the service using `ServiceObjects`

Type Parameters:
  `T` - The service type
Parameters:
  `ctx` - The bundle context
  `ref` - 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 using `ServiceObjects`

Type Parameters:
  `T` - The service type
Parameters:
  `ctx` - The bundle context
  `ref` - The service reference
  `service` - The service