Package com.framed.core.utils
Class RemoteUtils
java.lang.Object
com.framed.core.utils.RemoteUtils
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 Summary
Modifier and TypeMethodDescriptionstatic voidparseAndDispatch(String jsonStr, Map<String, List<Consumer<Object>>> handlers, Map<Consumer<Object>, ExecutorService> handlerExecutors) Parses a JSON message and submits it to registered handlers.static voidparseAndDispatchAsync(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.static RemoteMessageparseMessage(String jsonStr) Parses a JSON-encoded remote message into aRemoteMessage.
-
Method Details
-
parseMessage
Parses a JSON-encoded remote message into aRemoteMessage.- Parameters:
jsonStr- the JSON string containingaddress,payloadandtype- 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 dispatchhandlers- map of address to the handlers registered for that addressworkerPool- 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 dispatchhandlers- map of address to the handlers registered for that addresshandlerExecutors- map of handler to its dedicated single-thread executor, populated on demand for handlers that do not yet have one
-
