Class AnnotatedQueryHandlingComponent<T>
- Type Parameters:
T- The target type of this query handling component.
- All Implemented Interfaces:
DescribableComponent,MessageHandler,QueryHandler,QueryHandlingComponent
QueryHandler annotated
methods into a QueryHandlingComponent.
Each annotated method is subscribed as a QueryHandler at the QueryHandlingComponent with the query
name and response type specified by that method.
- Since:
- 3.1.0
- Author:
- Marc Gathier, Steven van Beelen
-
Constructor Summary
ConstructorsConstructorDescriptionAnnotatedQueryHandlingComponent(T annotatedQueryHandler, ParameterResolverFactory parameterResolverFactory, HandlerDefinition handlerDefinition, MessageTypeResolver messageTypeResolver, MessageConverter converter) Wraps the givenannotatedQueryHandler, allowing it to be subscribed to aQueryBusas aQueryHandlingComponent. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.handle(QueryMessage query, ProcessingContext context) Handles the givenquerywithin the givencontext.All supportedqueries, referenced through aQualifiedName.
-
Constructor Details
-
AnnotatedQueryHandlingComponent
public AnnotatedQueryHandlingComponent(@Nonnull T annotatedQueryHandler, @Nonnull ParameterResolverFactory parameterResolverFactory, @Nonnull HandlerDefinition handlerDefinition, @Nonnull MessageTypeResolver messageTypeResolver, @Nonnull MessageConverter converter) Wraps the givenannotatedQueryHandler, allowing it to be subscribed to aQueryBusas aQueryHandlingComponent.- Parameters:
annotatedQueryHandler- The object containing theQueryHandlerannotated methods.parameterResolverFactory- The parameter resolver factory to resolve handler parameters with.handlerDefinition- The handler definition used to create concrete handlers.messageTypeResolver- TheMessageTypeResolverresolving thenamesforQueryMessages.converter- The converter to use for converting the payload of the query to the type expected by the handling method.
-
-
Method Details
-
handle
@Nonnull public MessageStream<QueryResponseMessage> handle(@Nonnull QueryMessage query, @Nonnull ProcessingContext context) Description copied from interface:QueryHandlerHandles the givenquerywithin the givencontext.The resulting
streammay contain zero, one, or Nresponse messages.- Specified by:
handlein interfaceQueryHandler- Parameters:
query- The query to handle.context- The context to the givencommandis handled in.- Returns:
- A
MessagesStreamof zero, one, or Nresponse messages.
-
supportedQueries
Description copied from interface:QueryHandlingComponentAll supportedqueries, referenced through aQualifiedName.- Specified by:
supportedQueriesin interfaceQueryHandlingComponent- Returns:
- All supported
queries, referenced through aQualifiedName.
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.Best Practices: As a general rule, all relevant fields of a
DescribableComponentimplementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing thedescribeTomethod, who should focus on providing information that is useful for understanding the component's configuration and state.Example implementation:
public void describeTo(ComponentDescriptor descriptor) { descriptor.describeProperty("name", this.name); descriptor.describeProperty("enabled", this.enabled); descriptor.describeProperty("configuration", this.configuration); // A nested component descriptor.describeProperty("handlers", this.eventHandlers); // A collection }- Specified by:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-