Class DeadEvent

java.lang.Object
cloud.opencode.base.event.Event
cloud.opencode.base.event.DeadEvent

public final class DeadEvent extends Event
Dead Event - Wraps events that have no subscribers 死事件 - 包装没有订阅者的事件

When an event is published but no listeners are registered for its type, the event bus wraps it in a DeadEvent and re-dispatches it. This allows monitoring and debugging of unhandled events.

当事件被发布但没有任何监听器注册其类型时,事件总线将其包装为 DeadEvent 并重新分发。 这允许监控和调试未处理的事件。

Features | 主要功能:

  • Wraps unhandled events - 包装未处理的事件
  • Preserves original event - 保留原始事件
  • Enables dead event monitoring - 启用死事件监控

Usage Examples | 使用示例:

// Monitor dead events
eventBus.on(DeadEvent.class, dead -> {
    log.warn("Unhandled event: type={}, id={}",
        dead.getOriginalEvent().getClass().getSimpleName(),
        dead.getOriginalEvent().getId());
});

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
Since:
JDK 25, opencode-base-event V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • DeadEvent

      public DeadEvent(Event originalEvent)
      Create a dead event wrapping the original unhandled event 创建包装原始未处理事件的死事件
      Parameters:
      originalEvent - the event that had no subscribers | 没有订阅者的事件
      Throws:
      NullPointerException - if originalEvent is null | 如果 originalEvent 为 null
  • Method Details

    • getOriginalEvent

      public Event getOriginalEvent()
      Get the original event that had no subscribers 获取没有订阅者的原始事件
      Returns:
      the original event | 原始事件
    • toString

      public String toString()
      Overrides:
      toString in class Event