Interface QueryHandlingModule.QueryHandlerPhase

All Superinterfaces:
ModuleBuilder<QueryHandlingModule>
Enclosing interface:
QueryHandlingModule

public static interface QueryHandlingModule.QueryHandlerPhase extends ModuleBuilder<QueryHandlingModule>
The query handler configuration phase of the query handling module.

Every registered QueryHandler will be subscribed with the QueryBus of the ApplicationConfigurer this module is given to.

Provides roughly two options for configuring query handlers. Firstly, a query handler can be registered as is, through the queryHandler(QualifiedName, QueryHandler) method. Secondly, if the query handler provides components from the Configuration, a builder of the query handler can be registered through the queryHandler(QualifiedName, ComponentBuilder) method.

  • Method Details

    • queryHandler

      default QueryHandlingModule.QueryHandlerPhase queryHandler(@Nonnull QualifiedName queryName, @Nonnull QueryHandler queryHandler)
      Registers the given queryHandler for the given qualified queryName and responseName within this module.

      Use this query handler registration method when the query handler in question does not require entities or receives entities through another mechanism. Using a MessageTypeResolver to derive the queryName is beneficial to ensure consistent naming across handler subscriptions.

      Once this module is finalized, the query handler will be subscribed with the QueryBus of the ApplicationConfigurer the module is registered on.

      Parameters:
      queryName - The qualified name of the query the given queryHandler can handle.
      queryHandler - The query handler to register with this module.
      Returns:
      The query handler phase of this builder, for a fluent API.
    • queryHandler

      QueryHandlingModule.QueryHandlerPhase queryHandler(@Nonnull QualifiedName queryName, @Nonnull ComponentBuilder<QueryHandler> queryHandlerBuilder)
      Registers the given queryHandlerBuilder for the given qualified queryName within this module.

      Using a MessageTypeResolver to derive the queryName is beneficial to ensure consistent naming across handler subscriptions.

      Once this module is finalized, the query handler from the queryHandlerBuilder will be subscribed with the QueryBus of the ApplicationConfigurer the module is registered on.

      Parameters:
      queryName - The qualified name of the query the QueryHandler created by the given queryHandlerBuilder.
      queryHandlerBuilder - A builder of a QueryHandler. Provides the Configuration to retrieve components from to use during construction of the query handler.
      Returns:
      The query handler phase of this builder, for a fluent API.
    • queryHandlingComponent

      QueryHandlingModule.QueryHandlerPhase queryHandlingComponent(@Nonnull ComponentBuilder<QueryHandlingComponent> handlingComponentBuilder)
      Registers the given handlingComponentBuilder within this module.

      Use this query handler registration method when the query handling component in question does not require entities or receives entities through another mechanism.

      Once this module is finalized, the resulting QueryHandlingComponent from the handlingComponentBuilder will be subscribed with the QueryBus of the ApplicationConfigurer the module is registered on.

      Parameters:
      handlingComponentBuilder - A builder of a QueryHandlingComponent. Provides the Configuration to retrieve components from to use during construction of the query handling component.
      Returns:
      The query handler phase of this builder, for a fluent API.
    • annotatedQueryHandlingComponent

      default QueryHandlingModule.QueryHandlerPhase annotatedQueryHandlingComponent(@Nonnull ComponentBuilder<Object> handlingComponentBuilder)
      Registers the given handlingComponentBuilder as an AnnotatedQueryHandlingComponent within this module.

      This will scan the given handlingComponentBuilder for methods annotated with QueryHandler and register them as query handlers for the QueryBus of the ApplicationConfigurer.

      Parameters:
      handlingComponentBuilder - A builder of a QueryHandlingComponent. Provides the Configuration to retrieve components from to use during construction of the query handling component.
      Returns:
      The query handler phase of this builder, for a fluent API.