Interface LifecycleEventManager<O extends LifecycleEventOwner>
- Type Parameters:
O- the owning type,PluginorBootstrapContext
Manages a plugin's lifecycle events. Can be obtained
from
Plugin or BootstrapContext.-
Method Summary
Modifier and TypeMethodDescriptionvoidregisterEventHandler(LifecycleEventHandlerConfiguration<? super O> handlerConfiguration) Registers an event handler configuration.default <E extends LifecycleEvent>
voidregisterEventHandler(LifecycleEventType<? super O, ? extends E, ?> eventType, LifecycleEventHandler<? super E> eventHandler) Registers an event handler for a specific event type.
-
Method Details
-
registerEventHandler
default <E extends LifecycleEvent> void registerEventHandler(LifecycleEventType<? super O, ? extends E, ?> eventType, LifecycleEventHandler<? super E> eventHandler) Registers an event handler for a specific event type.This is shorthand for creating a new
LifecycleEventHandlerConfigurationand just passing in theLifecycleEventHandler.
is equivalent toLifecycleEventHandler<RegistrarEvent<Commands>> handler = new Handler(); manager.registerEventHandler(LifecycleEvents.COMMANDS, handler);LifecycleEventHandler<RegistrarEvent<Commands>> handler = new Handler(); manager.registerEventHandler(LifecycleEvents.COMMANDS.newHandler(handler));- Type Parameters:
E- the type of the event object- Parameters:
eventType- the event type to listen toeventHandler- the handler for that event
-
registerEventHandler
Registers an event handler configuration.Configurations are created via
LifecycleEventType.newHandler(LifecycleEventHandler). Event types may have different configurations options available on the builder-like object returned byLifecycleEventType.newHandler(LifecycleEventHandler).- Parameters:
handlerConfiguration- the handler configuration to register
-