in src/main/java/org/apache/sling/adapter/internal/AdapterManagerImpl.java [285:323]
private void unregisterAdapterFactory(final ServiceReference<AdapterFactory> reference) {
final List<AdapterFactoryDescriptorMap> list = new ArrayList<>();
synchronized ( this.descriptors ) {
for(final AdapterFactoryDescriptorMap map : this.descriptors.values()) {
list.add(map);
}
}
AdapterFactoryDescriptor removedDescriptor = null;
for(final AdapterFactoryDescriptorMap map : list) {
synchronized (map ) {
final AdapterFactoryDescriptor factoryDesc = map.remove(reference);
if (factoryDesc != null) {
removedDescriptor = factoryDesc;
}
}
}
// unregister adaption
if (removedDescriptor != null) {
// only remove cache if some adapter factories have actually been
// removed
this.factoryCache.clear();
final ServiceRegistration<Adaption> reg = removedDescriptor.getAdaption();
if ( reg != null ) {
removedDescriptor.setAdaption(null);
try {
reg.unregister();
} catch ( final IllegalStateException ignore) {
// ignore IAE on shutdown
}
}
if (log.isDebugEnabled()) {
log.debug("Unregistered service {} with {} : {} and {} : {}", new Object[] { Adaption.class.getName(),
SlingConstants.PROPERTY_ADAPTABLE_CLASSES, Arrays.toString(removedDescriptor.getAdaptables()),
SlingConstants.PROPERTY_ADAPTER_CLASSES, Arrays.toString(removedDescriptor.getAdapters()) });
}
}
}