in src/main/java/org/apache/sling/hc/support/impl/ScriptedHealthCheck.java [338:357]
public <T> T getService(Class<T> type) {
T service = (this.services == null ? null : (T) this.services.get(type.getName()));
if (service == null) {
final ServiceReference<?> ref = this.bundleContext.getServiceReference(type.getName());
if (ref != null) {
service = (T) this.bundleContext.getService(ref);
if (service != null) {
if (this.services == null) {
this.services = new HashMap<>();
}
if (this.references == null) {
this.references = new ArrayList<>();
}
this.references.add(ref);
this.services.put(type.getName(), service);
}
}
}
return service;
}