in src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java [61:79]
long registerService() {
final Bundle bundle = this.cache.getBundle();
final Dictionary<String, Object> props = new Hashtable<>();
props.put(Constants.SERVICE_DESCRIPTION,
"Provider of bundle based resources from bundle " + String.valueOf(bundle.getBundleId()));
props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
props.put(ResourceProvider.PROPERTY_ROOT, this.root.getResourceRoot());
props.put(PROP_BUNDLE,bundle.getBundleId());
// SLING-11649 - If this bundle is not in the {@link Bundle#STARTING}, {@link Bundle#ACTIVE},
// or {@link Bundle#STOPPING} states or this bundle is a fragment bundle, then this
// bundle will have a null {@code BundleContext}.
BundleContext bundleContext = bundle.getBundleContext();
if (bundleContext == null) {
throw new IllegalStateException("No BundleContext was found");
}
serviceRegistration = bundleContext.registerService(ResourceProvider.class, this, props);
return (Long) serviceRegistration.getReference().getProperty(Constants.SERVICE_ID);
}