Interface AiServiceListenerRegistrar
- All Known Implementing Classes:
DefaultAiServiceListenerRegistrar
public interface AiServiceListenerRegistrar
A registrar for registering
AiServiceListeners.-
Method Summary
Modifier and TypeMethodDescription<T extends AiServiceEvent>
voidfireEvent(T event) Fires the given event to all registeredAiServiceListeners.static AiServiceListenerRegistrarRetrieves an instance ofAiServiceListenerRegistrar.static AiServiceListenerRegistrarnewInstance(boolean shouldThrowExceptionOnEventError) Retrieves an instance ofAiServiceListenerRegistrar.default voidregister(AiServiceListener<?>... listeners) Registers one or moreAiServiceListenerinstances to receiveAiServiceEventnotifications.<T extends AiServiceEvent>
voidregister(AiServiceListener<T> listener) Registers a listener to receiveAiServiceEventnotifications.default voidregister(Iterable<? extends AiServiceListener<?>> listeners) Registers a collection ofAiServiceListenerinstances to receiveAiServiceEventnotifications.voidshouldThrowExceptionOnEventError(boolean shouldThrowExceptionOnEventError) Configures whether exceptions should be thrown when an error occurs during event processing.default voidunregister(AiServiceListener<?>... listeners) Unregisters one or moreAiServiceListenerinstances to receiveAiServiceEventnotifications.<T extends AiServiceEvent>
voidunregister(AiServiceListener<T> listener) Unregisters a previously registeredAiServiceListener, stopping it from receiving furtherAiServiceEventnotifications.default voidunregister(Iterable<? extends AiServiceListener<?>> listeners) Unregisters a collection ofAiServiceListenerinstances to receiveAiServiceEventnotifications.
-
Method Details
-
register
Registers a listener to receiveAiServiceEventnotifications. -
register
Registers one or moreAiServiceListenerinstances to receiveAiServiceEventnotifications.- Parameters:
listeners- One or moreAiServiceListenerinstances to register. If null, no action will be taken.
-
register
Registers a collection ofAiServiceListenerinstances to receiveAiServiceEventnotifications. If the provided collection is null, no action is taken. Each listener in the collection is registered individually.- Parameters:
listeners- AnIterablecontaining instances ofAiServiceListenerto register. Each listener will be registered to receive notifications for its associated event type.
-
unregister
Unregisters a previously registeredAiServiceListener, stopping it from receiving furtherAiServiceEventnotifications. -
unregister
Unregisters one or moreAiServiceListenerinstances to receiveAiServiceEventnotifications.- Parameters:
listeners- One or moreAiServiceListenerinstances to unregister. If null, no action will be taken.
-
unregister
Unregisters a collection ofAiServiceListenerinstances to receiveAiServiceEventnotifications. If the provided collection is null, no action is taken. Each listener in the collection is unregistered individually.- Parameters:
listeners- AnIterablecontaining instances ofAiServiceListenerto unregister. Each listener will be registered to receive notifications for its associated event type.
-
fireEvent
Fires the given event to all registeredAiServiceListeners.- Type Parameters:
T- The type of the event, which must be a subtype ofAiServiceEvent.- Parameters:
event- The event to be fired to the listeners. Must not be null.
-
shouldThrowExceptionOnEventError
void shouldThrowExceptionOnEventError(boolean shouldThrowExceptionOnEventError) Configures whether exceptions should be thrown when an error occurs during event processing. If set totrue, any error that occurs while processing an event will result in an exception propagating to the caller. If set tofalse, errors will be silently handled or logged without interrupting the normal execution flow.- Parameters:
shouldThrowExceptionOnEventError- Indicates whether to throw exceptions on event errors. Iftrue, exceptions will be thrown; otherwise, errors will be handled silently. Default isfalse.
-
newInstance
Retrieves an instance ofAiServiceListenerRegistrar. This method first attempts to load an instance ofAiServiceListenerRegistrarusingServiceLoader. If no implementation is found, the default instance provided bynewInstance()is returned.Simply calls
newInstance(boolean), passingfalseas the argument. -
newInstance
Retrieves an instance ofAiServiceListenerRegistrar. This method first attempts to load an instance ofAiServiceListenerRegistrarusingServiceLoader. If no implementation is found, the default instance provided bynewInstance()is returned.- Parameters:
shouldThrowExceptionOnEventError- Indicates whether to throw exceptions on event errors. Iftrue, exceptions will be thrown; otherwise, errors will be handled silently.
-