Class InterceptingQueryHandlingComponent
- All Implemented Interfaces:
DescribableComponent,MessageHandler,QueryHandler,QueryHandlingComponent
QueryHandlingComponent that applies a list of interceptors around every
query before delegating to the underlying component.
Interceptors are invoked in registration order. Each interceptor can inspect the query, modify it, short-circuit handling, or proceed to the next interceptor in the chain.
- Since:
- 5.2.0
- Author:
- Allard Buijze
-
Constructor Summary
ConstructorsConstructorDescriptionInterceptingQueryHandlingComponent(List<MessageHandlerInterceptor<? super QueryMessage>> interceptors, QueryHandlingComponent delegate) Constructs a newInterceptingQueryHandlingComponentwrapping the givendelegatewith the giveninterceptors. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.handle(QueryMessage query, ProcessingContext processingContext) Handles the givenquerywithin the givencontext.All supportedqueries, referenced through aQualifiedName.
-
Constructor Details
-
InterceptingQueryHandlingComponent
public InterceptingQueryHandlingComponent(List<MessageHandlerInterceptor<? super QueryMessage>> interceptors, QueryHandlingComponent delegate) Constructs a newInterceptingQueryHandlingComponentwrapping the givendelegatewith the giveninterceptors.- Parameters:
interceptors- the interceptors to apply, in invocation orderdelegate- the underlying component to delegate to after all interceptors have proceeded
-
-
Method Details
-
handle
public MessageStream<QueryResponseMessage> handle(QueryMessage query, ProcessingContext processingContext) 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.processingContext- 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.
-