Class CardTypeRegistry

java.lang.Object
org.apache.juneau.console.CardTypeRegistry

public final class CardTypeRegistry extends Object
The open set of server-side card type handlers. standard() holds the built-ins (html), every CardTypeHandler found through ServiceLoader (this is how console-ui-freemarker contributes datatables and terminal), and falls back to the generic passthrough for unknown types. standard() is immutable; a host that adds its own types works on a copy(), so one host's types never leak into another's.
Example:

CardTypeRegistry r = CardTypeRegistry.standard().copy() .add(new KpiCardType()) // E-21 bad name, E-22 reserved, E-20 duplicate .build(); JsonMap card = r.toCard(source); // base keys + fragment, reserved-key check

Since:
10.0.0
  • Field Details

    • RESERVED

      public static final Set<String> RESERVED
      Reserved type names: html (built in), datatables, terminal-view, terminal, chart and job-log (console-ui-freemarker).
  • Method Details

    • standard

      public static CardTypeRegistry standard()
      Returns:
      The standard registry: html plus every ServiceLoader-discovered handler.
    • copy

      Returns:
      A CardTypeRegistry.Builder pre-seeded with this registry's handlers, to add more on top.
    • handler

      Parameters:
      type - The card type name.
      Returns:
      The registered handler for type, or the generic passthrough when none is registered.
    • isRegistered

      public boolean isRegistered(String type)
      Parameters:
      type - The card type name.
      Returns:
      true if a handler is registered for type (not counting the generic fallback).
    • types

      public Set<String> types()
      Returns:
      Every registered type name.
    • toCard

      public JsonMap toCard(CardSource source)
      The single server path for both <@card> and C3's PageSpec: validates the body (E-23), dispatches to handler(String), and merges the fragment flat onto the card's base keys. A JSON body's visibleWhen, subscribes and publishes are promoted onto the card itself (the handler never sees subscribes/publishes).
      Parameters:
      source - The authored card.
      Returns:
      The card object: base keys plus the handler's fragment, flat.
      Throws:
      IllegalArgumentException - E-23 if the body sets a reserved key; if src is not a same-origin path (see SafePathTemplate.isSameOriginPath(String); a {token} placeholder is allowed); or from the handler itself.