Package studio.mevera.imperat.events
Class EventBus.Builder
java.lang.Object
studio.mevera.imperat.events.EventBus.Builder
- Enclosing interface:
- EventBus
Builder for creating configured
EventBus instances.
EventBus eventBus = EventBus.builder()
.exceptionHandler((event, ex, id) -> logger.error("Handler failed", ex))
.executorService(myCustomExecutor)
.build();
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds and returns a configuredEventBus.exceptionHandler(@Nullable EventExceptionHandler handler) Sets the global exception handler.executorService(@Nullable ExecutorService executorService) Sets a customExecutorServicefor async handler execution.
-
Method Details
-
exceptionHandler
Sets the global exception handler.Invoked with full context whenever any registered handler throws an exception. Optional — if not set, exceptions are silently ignored.
- Parameters:
handler- the exception handler, or null to leave unset- Returns:
- this builder
-
executorService
Sets a customExecutorServicefor async handler execution.If not set, a default daemon cached thread pool is created and owned by the bus. If you supply one here, you are responsible for shutting it down independently.
- Parameters:
executorService- the executor service, or null to use the default- Returns:
- this builder
-
build
Builds and returns a configuredEventBus.- Returns:
- a new EventBus instance
-