Class PluginEventSubscriptionsImpl

java.lang.Object
com.xebialabs.xlrelease.osgi.spring.PluginEventSubscriptionsImpl
All Implemented Interfaces:
com.xebialabs.xlrelease.osgi.api.spring.PluginEventSubscriptions

@Component public class PluginEventSubscriptionsImpl extends Object implements com.xebialabs.xlrelease.osgi.api.spring.PluginEventSubscriptions
A single instance is shared between the root host ApplicationContext (as this @Component) and every plugin's curated parent context (PluginApiParentContext registers the exact same object as a singleton there), mirroring PluginExtensionRegistryImpl's sharing pattern.

Subscriptions are tracked by the ClassLoader active on the calling thread at subscribe(...) time, not by an explicit plugin identifier - subscribe has no such parameter. This relies on PluginContextFactory/PluginExecutionContext pinning the TCCL to the owning bundle's classloader for every plugin code execution path (context refresh, and eventually request handling and extension invocation), so Thread.currentThread().getContextClassLoader() reliably identifies "which plugin is calling right now" wherever a plugin bean's own code runs.

  • Constructor Details

    • PluginEventSubscriptionsImpl

      public PluginEventSubscriptionsImpl(XLReleaseEventBus eventBus)
  • Method Details

    • subscribe

      public AutoCloseable subscribe(Class<?> eventType, Consumer<Object> handler)
      Specified by:
      subscribe in interface com.xebialabs.xlrelease.osgi.api.spring.PluginEventSubscriptions
    • closeAll

      public void closeAll(ClassLoader owner)
      Closes every still-open handle issued under owner, even ones the plugin author forgot to close. Called by PluginTeardown as one ordered teardown step. Idempotent: a second call for the same, already-cleared owner finds nothing and is a no-op.