in src/main/java/org/apache/sling/resourceresolver/impl/legacy/LegacyResourceProviderWhiteboard.java [131:181]
protected void bindResourceProviderFactory(final ServiceReference<ResourceProviderFactory> ref) {
final BundleContext bundleContext = ref.getBundle().getBundleContext();
final ResourceProviderFactory factory = bundleContext.getService(ref);
if (factory != null) {
final String[] propertyNames = ref.getPropertyKeys();
final boolean ownsRoot = Converters.standardConverter()
.convert(ref.getProperty(OWNS_ROOTS))
.to(boolean.class);
final List<ServiceRegistration> newServices = new ArrayList<>();
for (final String path : Converters.standardConverter()
.convert(ref.getProperty(ROOTS))
.to(String[].class)) {
if (path != null && !path.isEmpty()) {
final Dictionary<String, Object> newProps = new Hashtable<>();
if (Converters.standardConverter()
.convert(ref.getProperty(PROPERTY_REQUIRED))
.to(boolean.class)) {
newProps.put(PROPERTY_AUTHENTICATE, AuthType.required.toString());
} else {
newProps.put(PROPERTY_AUTHENTICATE, AuthType.lazy.toString());
}
newProps.put(PROPERTY_MODIFIABLE, true);
newProps.put(PROPERTY_ADAPTABLE, true);
newProps.put(PROPERTY_ATTRIBUTABLE, true);
newProps.put(PROPERTY_REFRESHABLE, true);
newProps.put(PROPERTY_NAME, factory.getClass().getName());
newProps.put(PROPERTY_ROOT, normalizePath(path));
if (ArrayUtils.contains(propertyNames, SERVICE_PID)) {
newProps.put(ORIGINAL_SERVICE_PID, ref.getProperty(SERVICE_PID));
}
if (ArrayUtils.contains(propertyNames, USE_RESOURCE_ACCESS_SECURITY)) {
newProps.put(
PROPERTY_USE_RESOURCE_ACCESS_SECURITY, ref.getProperty(USE_RESOURCE_ACCESS_SECURITY));
}
if (ArrayUtils.contains(propertyNames, SERVICE_RANKING)) {
newProps.put(SERVICE_RANKING, ref.getProperty(SERVICE_RANKING));
}
String[] languages = Converters.standardConverter()
.convert(ref.getProperty(LANGUAGES))
.to(String[].class);
ServiceRegistration reg = bundleContext.registerService(
org.apache.sling.spi.resource.provider.ResourceProvider.class.getName(),
new LegacyResourceProviderFactoryAdapter(factory, languages, ownsRoot),
newProps);
newServices.add(reg);
}
}
registrations.put(factory, newServices);
}
}