shared Subscribe Logic
Shared internal logic for registering both event handlers and exception handlers.
This method unifies the subscription flow for:
instance-based handlers (event or exception),
static handlers (event or exception),
any handler type implementing Priority.
Responsibilities
Insert the handler into the appropriate list within methodCache, maintaining descending priority order (higher values run first).
Record handler ownership in either:
objectCache — when any is non-null (instance subscriber), or
staticCache — when type is non-null (static subscriber class).
Usage
This function is used for:
normal event handler registration,
exception handler registration,
both instance and static subscriptions.
By abstracting the storage and bookkeeping rules, the event system avoids duplicated logic for events vs. exceptions.
Cache Invalidation
This function does not clear any resolved-handler caches. Callers are responsible for invalidating:
resolvedEventCachefor event handlers, orexceptionResolvedCachefor exception handlers.
after completing all registration work.
Parameters
the handler entry type (e.g. EventHandlerEntry, ExceptionHandlerEntry).
cache from event type to the mutable list of handlers associated with it.
Caffeine cache tracking which event types an instance subscriber owns handlers for.
cache tracking which event types a static subscriber class owns handlers for.
the event type under which this handler should be registered.
the handler’s priority; higher values are ordered earlier.
the fully constructed handler entry.
instance subscriber, or null if registering a static handler.
static subscriber class, or null if registering an instance handler.