in src/main/java/org/apache/sling/scripting/core/ScriptHelper.java [209:228]
public <T> T getService(Class<T> type) {
T service = (this.services == null ? null : (T) this.services.get(type.getName()));
if (service == null) {
final ServiceReference<T> ref = this.bundleContext.getServiceReference(type);
if (ref != null) {
service = 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;
}