Class BusPolicy.Builder

java.lang.Object
org.apache.juneau.console.bus.BusPolicy.Builder
Enclosing class:
BusPolicy

public static final class BusPolicy.Builder extends Object
Builder for BusPolicy.
Example:

BusPolicy p = BusPolicy.create() .downstream("ops.jobs", true) .sessionAttributes(req -> Map.of("region", req.getHeader("X-Region"))) .maxSessions(64) .build();

  • Method Details

    • downstream

      public BusPolicy.Builder downstream(String topicPattern, boolean retain)
      Allows a topic pattern downstream (server → page).
      Parameters:
      topicPattern - ns.name, ns.name:key, ns.name:*, job:<id>, job:* or cmd:<cardId>.
      retain - Whether values are retained and resent on every (re)connect.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - E-57 on an invalid or repeated pattern.
    • upstream

      Allows an exact custom topic upstream (page → server, WebSocket only) and names its handler.
      Parameters:
      topic - The topic (ns.name or ns.name:key).
      handler - The handler. Must not be null.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - E-57 on an invalid or repeated topic, or a null handler.
    • authorizer

      public BusPolicy.Builder authorizer(BiPredicate<jakarta.servlet.http.HttpServletRequest,String> value)
      Sets a per-request, per-topic authorizer, consulted for every requested topic at session open.
      Parameters:
      value - The authorizer. Must not be null.
      Returns:
      This object.
    • boundary

      Sets the request boundary. The session POST and SSE stream apply its check.

      The WebSocket handshake cannot run check, so it applies the boundary's own handshake rules: a LoopbackBoundary's exact origin() and authority(), or a CsrfBoundary's Origin match against the handshake's own Host and scheme. BusWebSockets.register refuses any other boundary type.

      Parameters:
      value - The boundary. Can be null.
      Returns:
      This object.
    • allowedOrigins

      Sets the exact origins a WebSocket handshake may carry when no boundary is set. Ignored when a boundary is set.
      Parameters:
      values - Origins such as https://console.example.org. None may be blank.
      Returns:
      This object.
    • sessionGrace

      Parameters:
      value - Grace after the last connection closes. Default 60 s. @return This object.
    • maxSessionAge

      Parameters:
      value - Absolute session lifetime. Default 12 h. @return This object.
    • heartbeat

      Parameters:
      value - Idle interval before a ping frame. Default 15 s. @return This object.
    • maxSessions

      public BusPolicy.Builder maxSessions(int value)
      Parameters:
      value - Maximum live sessions. Default 256. @return This object.
    • maxQueuedFrames

      public BusPolicy.Builder maxQueuedFrames(int value)
      Parameters:
      value - Per-connection outbound queue bound. Default 1024. @return This object.
    • maxFrameBytes

      public BusPolicy.Builder maxFrameBytes(int value)
      Parameters:
      value - Maximum encoded frame size, UTF-8 bytes. Default 65536. @return This object.
    • maxUpstreamPerSecond

      Parameters:
      value - Per-session upstream frames per second. Default 20. @return This object.
    • sessionAttributes

      public BusPolicy.Builder sessionAttributes(Function<jakarta.servlet.http.HttpServletRequest,Map<String,Object>> value)
      Sets the function that captures attributes onto each BusSession at session open.
      Parameters:
      value - The function. Must not be null; it may return null for "none".
      Returns:
      This object.
    • build

      public BusPolicy build()
      Builds the policy.
      Returns:
      A new immutable policy.