use of org.apache.sling.junit.RendererFactory in project sling by apache.
the class RendererSelectorImpl method getRenderer.
public Renderer getRenderer(TestSelector selector) {
if (renderersTracker.getTrackingCount() != renderersTrackerTrackingCount) {
log.debug("Rebuilding list of {}", Renderer.class.getSimpleName());
renderersTrackerTrackingCount = renderersTracker.getTrackingCount();
final ServiceReference[] refs = renderersTracker.getServiceReferences();
renderers.clear();
if (refs != null) {
for (ServiceReference ref : refs) {
renderers.add((Renderer) bundleContext.getService(ref));
}
}
log.info("List of {} rebuilt: {}", Renderer.class.getSimpleName(), renderers);
}
for (Renderer r : renderers) {
if (r.appliesTo(selector)) {
if (r instanceof RendererFactory) {
return ((RendererFactory) r).createRenderer();
}
throw new UnsupportedOperationException("Renderers must implement RendererFactory, this one does not:" + r);
}
}
return null;
}
Aggregations