in src/main/java/org/apache/sling/bundleresource/impl/Activator.java [111:152]
private void addBundleResourceProvider(final Bundle bundle) {
BundleResourceProvider[] providers = null;
try {
synchronized (this) {
// on startup we might get here twice for a bundle (listener and activator)
if (bundleResourceProviderMap.get(bundle.getBundleId()) != null) {
return;
}
final String prefixes = bundle.getHeaders().get(BUNDLE_RESOURCE_ROOTS);
if (prefixes != null) {
log.debug(
"addBundleResourceProvider: Registering resources '{}' for bundle {}:{} ({}) as service ",
new Object[] {prefixes, bundle.getSymbolicName(), bundle.getVersion(), bundle.getBundleId()
});
final PathMapping[] roots = PathMapping.getRoots(prefixes);
providers = new BundleResourceProvider[roots.length];
int index = 0;
final BundleResourceCache cache = new BundleResourceCache(bundle);
for (final PathMapping path : roots) {
final BundleResourceProvider brp = new BundleResourceProvider(cache, path);
providers[index] = brp;
index++;
}
bundleResourceProviderMap.put(bundle.getBundleId(), providers);
}
}
if (providers != null) {
for (final BundleResourceProvider provider : providers) {
final long id = provider.registerService();
log.debug("addBundleResourceProvider: Service ID = {}", id);
}
}
} catch (final Throwable t) {
log.error(
"activate: Problem while registering bundle resources for bundle " + bundle.getSymbolicName() + ":"
+ bundle.getVersion() + " (" + bundle.getBundleId() + ")",
t);
}
}