Package com.yahoo.search.rendering
Class RendererRegistry
- java.lang.Object
-
- com.yahoo.component.provider.ComponentRegistry<com.yahoo.processing.rendering.Renderer<Result>>
-
- com.yahoo.search.rendering.RendererRegistry
-
public final class RendererRegistry extends com.yahoo.component.provider.ComponentRegistry<com.yahoo.processing.rendering.Renderer<Result>>
Holds all configured and built-in renderers. This registry is always frozen.- Author:
- bratseth
-
-
Field Summary
Fields Modifier and Type Field Description static com.yahoo.component.ComponentId
defaultRendererId
static com.yahoo.component.ComponentId
jsonRendererId
static com.yahoo.component.ComponentId
pageRendererId
static com.yahoo.component.ComponentId
xmlRendererId
-
Constructor Summary
Constructors Constructor Description RendererRegistry()
Creates a registry containing the built-in renderers onlyRendererRegistry(java.util.Collection<com.yahoo.processing.rendering.Renderer> renderers)
Creates a registry of the given renderers plus the built-in onesRendererRegistry(java.util.Collection<com.yahoo.processing.rendering.Renderer> renderers, java.util.concurrent.Executor executor)
Creates a registry of the given renderers plus the built-in ones, using a custom executor.RendererRegistry(java.util.concurrent.Executor executor)
Creates a registry containing the built-in renderers only, using a custom executor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deconstruct()
Must be called when use of this is discontinued to free the resources it has allocatedcom.yahoo.processing.rendering.Renderer<Result>
getDefaultRenderer()
Returns the default JSON renderercom.yahoo.processing.rendering.Renderer<Result>
getRenderer(com.yahoo.component.ComponentSpecification format)
Returns the requested renderer.
-
-
-
Field Detail
-
xmlRendererId
public static final com.yahoo.component.ComponentId xmlRendererId
-
pageRendererId
public static final com.yahoo.component.ComponentId pageRendererId
-
jsonRendererId
public static final com.yahoo.component.ComponentId jsonRendererId
-
defaultRendererId
public static final com.yahoo.component.ComponentId defaultRendererId
-
-
Constructor Detail
-
RendererRegistry
public RendererRegistry()
Creates a registry containing the built-in renderers only
-
RendererRegistry
public RendererRegistry(java.util.concurrent.Executor executor)
Creates a registry containing the built-in renderers only, using a custom executor. Using a custom executor is useful for tests to avoid creating new threads for each renderer registry: Use MoreExecutors.directExecutor().
-
RendererRegistry
public RendererRegistry(java.util.Collection<com.yahoo.processing.rendering.Renderer> renderers)
Creates a registry of the given renderers plus the built-in ones
-
RendererRegistry
public RendererRegistry(java.util.Collection<com.yahoo.processing.rendering.Renderer> renderers, java.util.concurrent.Executor executor)
Creates a registry of the given renderers plus the built-in ones, using a custom executor. Using a custom executor is useful for tests to avoid creating new threads for each renderer registry.
-
-
Method Detail
-
deconstruct
public void deconstruct()
Must be called when use of this is discontinued to free the resources it has allocated
-
getDefaultRenderer
public com.yahoo.processing.rendering.Renderer<Result> getDefaultRenderer()
Returns the default JSON renderer- Returns:
- the default built-in result renderer
-
getRenderer
public com.yahoo.processing.rendering.Renderer<Result> getRenderer(com.yahoo.component.ComponentSpecification format)
Returns the requested renderer.- Parameters:
format
- the id or format alias of the renderer to return. If null is passed the default renderer is returned- Throws:
java.lang.IllegalArgumentException
- if the renderer cannot be resolved
-
-