Interface PluginEventSubscriptions


public interface PluginEventSubscriptions
The only supported way for plugin code to subscribe to host events. Plugin beans @Autowired this instead of the host's raw event bus - subscriptions made by bypassing it (using the host bus directly) are against the plugin-author contract and are not cleaned up automatically on plugin teardown; they will leak.
  • Method Summary

    Modifier and Type
    Method
    Description
    subscribe(Class<?> eventType, Consumer<Object> handler)
    Subscribes handler to every published event assignable to eventType.
  • Method Details

    • subscribe

      AutoCloseable subscribe(Class<?> eventType, Consumer<Object> handler)
      Subscribes handler to every published event assignable to eventType.
      Returns:
      a handle whose close() deregisters the subscription. Plugin teardown closes every handle issued to a plugin automatically, even ones the plugin author forgot to close, but authors should still close what they no longer need promptly.