in src/main/java/org/apache/sling/adapter/internal/AdapterManagerImpl.java [106:135]
public <AdapterType> AdapterType getAdapter(final Object adaptable, final Class<AdapterType> type) {
// get the adapter factories for the type of adaptable object
final Map<String, List<AdapterFactoryDescriptor>> factories = getAdapterFactories(adaptable.getClass());
// get the factory for the target type
final List<AdapterFactoryDescriptor> descList = factories.get(type.getName());
if (descList != null && descList.size() > 0) {
for (AdapterFactoryDescriptor desc : descList) {
final AdapterFactory factory = desc.getFactory();
// have the factory adapt the adaptable if the factory exists
if (factory != null) {
log.debug("Trying adapter factory {} to map {} to {}", new Object[] {factory, adaptable, type});
AdapterType adaptedObject = factory.getAdapter(adaptable, type);
if (adaptedObject != null) {
log.debug("Using adapter factory {} to map {} to {}", new Object[] {factory, adaptable, type});
return adaptedObject;
}
}
}
}
// no factory has been found, so we cannot adapt
log.debug("No adapter factory found to map {} to {}", adaptable, type);
return null;
}