Class LogRendererRegistry
java.lang.Object
org.jpos.log.LogRendererRegistry
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddump(PrintStream ps) Dumps the current state of the registry to the specifiedPrintStream.static <T> LogRenderer<T> getRenderer(Class<?> clazz, LogRenderer.Type type) Retrieves aLogRendererthat matches the specified class and type.static <T> voidregister(LogRenderer<?> renderer) Registers aLogRendererin the registry with a key generated from the renderer's class and type.
-
Constructor Details
-
LogRendererRegistry
public LogRendererRegistry()
-
-
Method Details
-
register
Registers aLogRendererin 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
Dumps the current state of the registry to the specifiedPrintStream.- Parameters:
ps- ThePrintStreamto which the dump will be written, e.g.: System.out
-
getRenderer
Retrieves aLogRendererthat 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 forObject, 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.
-