Class RemoteUtils

java.lang.Object
com.framed.core.utils.RemoteUtils

public class RemoteUtils extends Object
Utility methods for parsing and dispatching JSON-encoded remote messages to registered handlers. Used by transport-backed event bus implementations to decode incoming wire messages and route their payloads to the appropriate consumers.
  • Method Details

    • parseMessage

      public static RemoteMessage parseMessage(String jsonStr)
      Parses a JSON-encoded remote message into a RemoteMessage.
      Parameters:
      jsonStr - the JSON string containing address, payload and type
      Returns:
      the decoded remote message
    • parseAndDispatchAsync

      public static void parseAndDispatchAsync(String jsonStr, Map<String,List<Consumer<Object>>> handlers, ExecutorService workerPool)
      Parses a JSON message and submits it to registered handlers, creating a thread per handler.
      Parameters:
      jsonStr - the JSON string representing the message to parse and dispatch
      handlers - map of address to the handlers registered for that address
      workerPool - the worker pool of the transport used to run each handler invocation
    • parseAndDispatch

      public static void parseAndDispatch(String jsonStr, Map<String,List<Consumer<Object>>> handlers, Map<Consumer<Object>,ExecutorService> handlerExecutors)
      Parses a JSON message and submits it to registered handlers.

      Each handler is dispatched on its own dedicated single-thread executor (created on demand and cached in handlerExecutors), preserving per-handler FIFO ordering.

      Parameters:
      jsonStr - the JSON string representing the message to parse and dispatch
      handlers - map of address to the handlers registered for that address
      handlerExecutors - map of handler to its dedicated single-thread executor, populated on demand for handlers that do not yet have one