Class LogRendererRegistry

java.lang.Object
org.jpos.log.LogRendererRegistry

public class LogRendererRegistry extends Object
A registry for managing LogRenderer instances associated with specific class types and renderer types. This class allows for the registration, retrieval, and management of LogRenderer instances dynamically, using a thread-safe approach to ensure proper operation in multi-threaded environments.
  • Constructor Details

  • Method Details

    • register

      public static <T> void register(LogRenderer<?> renderer)
      Registers a LogRenderer in the registry with a key generated from the renderer's class and type.
      Parameters:
      renderer - The renderer to register. Must not be null.
      Throws:
      NullPointerException - if the renderer is null.
    • dump

      public static void dump(PrintStream ps)
      Dumps the current state of the registry to the specified PrintStream.
      Parameters:
      ps - The PrintStream to which the dump will be written, e.g.: System.out
    • getRenderer

      public static <T> LogRenderer<T> getRenderer(Class<?> clazz, LogRenderer.Type type)
      Retrieves a LogRenderer that matches the specified class and type. If no direct match is found, it attempts to find a renderer for any superclass or implemented interfaces. If no specific renderer is found, it defaults to a renderer for Object, if present for the given type.
      Parameters:
      clazz - The class for which a renderer is required.
      type - The type of the renderer.
      Returns:
      The matching LogRenderer, or a default renderer if no specific match is found.