Class ResponseWritersRegistry

java.lang.Object
org.apache.solr.response.ResponseWritersRegistry

public class ResponseWritersRegistry extends Object
Essential response writers always available regardless of core configuration.

Used by node/container-level requests that have no associated SolrCore.

For the full set of response writers see SolrCore's response writer registry.

  • Method Details

    • getWriter

      public static QueryResponseWriter getWriter(String writerName)
      Gets a built-in response writer.

      Built-in writers are always available and provide essential formats needed by admin APIs and core functionality. They do not depend on core configuration or ImplicitPlugins.json settings.

      If the requested writer is not available, returns the JSON writer as a fallback. This ensures requests always get a valid response format.

      Parameters:
      writerName - the writer name (e.g., "json", "xml", "javabin"), or null for default
      Returns:
      the response writer, never null (returns JSON if not found)
    • getWriter

      public static QueryResponseWriter getWriter(String writerName, SolrCore core)
      Gets a response writer, trying the core's registry first, then falling back to built-in writers. This is the unified entry point for all writer resolution.

      Resolution order:

      1. If core is provided, check core's writer registry
      2. If not found in core (or no core), check built-in writers
      3. If writer name is explicitly specified but not found anywhere, throw exception
      4. If writer name is null/empty, return default (JSON)
      Parameters:
      writerName - the writer name (e.g., "json", "xml", "javabin"), or null for default
      core - the SolrCore to check first, or null for node-level requests
      Returns:
      the response writer, never null
      Throws:
      org.apache.solr.common.SolrException - if an explicitly requested writer type is not found
    • hasWriter

      public static boolean hasWriter(String writerName)
      Checks if a writer with the given name exists in the built-in writers.
      Parameters:
      writerName - the writer name to check
      Returns:
      true if the writer exists, false otherwise
    • getAllWriters

      public static Map<String,QueryResponseWriter> getAllWriters()
      Gets all built-in response writers.
      Returns:
      immutable map of all built-in writers