code: private <T> T checkRegisteredOsgiServices(Class<T> serviceClazz, String key) throws InvalidSyntaxException {
      Collection<ServiceReference<T>> references = getBundleContext().getServiceReferences(serviceClazz, null);
      if (references == null || references.isEmpty()) {
        return null;
      }
      Collection<T> matches = checkIfClassNamesMatchKey(references, key);
      if (matches.size() == 1) {
        return matches.iterator().next();
      } else if (matches.size() > 1) {
        throw new RuntimeException("Too many " + serviceClazz + " registered with name: " + key);
      }
      // zero matches
      return null;
    }
docs: Checks the OSGi ServiceRegistry if a service matching the class and key are
  present. The class name has to match the key where the first letter has to
  be lower case.
  <p>
  For example:<br/>
  <code>
  public class MyServiceTask extends JavaDelegate</code> <br/>
  matches {@link JavaDelegate} with key "myServiceTask".
  
  @param serviceClazz
  @param key
  the name of the class
  @return null if no service could be found or the service object
  @throws RuntimeException
  if more than one service is found