Interface AiServiceListenerRegistrar

All Known Implementing Classes:
DefaultAiServiceListenerRegistrar

public interface AiServiceListenerRegistrar
A registrar for registering AiServiceListeners.
  • Method Details

    • register

      <T extends AiServiceEvent> void register(AiServiceListener<T> listener)
      Registers a listener to receive AiServiceEvent notifications.
    • register

      default void register(AiServiceListener<?>... listeners)
      Registers one or more AiServiceListener instances to receive AiServiceEvent notifications.
      Parameters:
      listeners - One or more AiServiceListener instances to register. If null, no action will be taken.
    • register

      default void register(Iterable<? extends AiServiceListener<?>> listeners)
      Registers a collection of AiServiceListener instances to receive AiServiceEvent notifications. If the provided collection is null, no action is taken. Each listener in the collection is registered individually.
      Parameters:
      listeners - An Iterable containing instances of AiServiceListener to register. Each listener will be registered to receive notifications for its associated event type.
    • unregister

      <T extends AiServiceEvent> void unregister(AiServiceListener<T> listener)
      Unregisters a previously registered AiServiceListener, stopping it from receiving further AiServiceEvent notifications.
    • unregister

      default void unregister(AiServiceListener<?>... listeners)
      Unregisters one or more AiServiceListener instances to receive AiServiceEvent notifications.
      Parameters:
      listeners - One or more AiServiceListener instances to unregister. If null, no action will be taken.
    • unregister

      default void unregister(Iterable<? extends AiServiceListener<?>> listeners)
      Unregisters a collection of AiServiceListener instances to receive AiServiceEvent notifications. If the provided collection is null, no action is taken. Each listener in the collection is unregistered individually.
      Parameters:
      listeners - An Iterable containing instances of AiServiceListener to unregister. Each listener will be registered to receive notifications for its associated event type.
    • fireEvent

      <T extends AiServiceEvent> void fireEvent(T event)
      Fires the given event to all registered AiServiceListeners.
      Type Parameters:
      T - The type of the event, which must be a subtype of AiServiceEvent.
      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 to true, any error that occurs while processing an event will result in an exception propagating to the caller. If set to false, errors will be silently handled or logged without interrupting the normal execution flow.
      Parameters:
      shouldThrowExceptionOnEventError - Indicates whether to throw exceptions on event errors. If true, exceptions will be thrown; otherwise, errors will be handled silently. Default is false.
    • newInstance

      static AiServiceListenerRegistrar newInstance()
      Retrieves an instance of AiServiceListenerRegistrar. This method first attempts to load an instance of AiServiceListenerRegistrar using ServiceLoader. If no implementation is found, the default instance provided by newInstance() is returned.

      Simply calls newInstance(boolean), passing false as the argument.

    • newInstance

      static AiServiceListenerRegistrar newInstance(boolean shouldThrowExceptionOnEventError)
      Retrieves an instance of AiServiceListenerRegistrar. This method first attempts to load an instance of AiServiceListenerRegistrar using ServiceLoader. If no implementation is found, the default instance provided by newInstance() is returned.
      Parameters:
      shouldThrowExceptionOnEventError - Indicates whether to throw exceptions on event errors. If true, exceptions will be thrown; otherwise, errors will be handled silently.