Class DefaultHandlerInterceptorRegistry
- All Implemented Interfaces:
DescribableComponent,HandlerInterceptorRegistry
HandlerInterceptorRegistry, maintaining lists of CommandMessage,
EventMessage, and QueryMessage-specific
MessageHandlerInterceptors.
This implementation ensures give interceptor builders methods are only invoked once.
Note that this does not apply to given factories!
- Since:
- 5.0.0
- Author:
- Steven van Beelen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<MessageHandlerInterceptor<? super CommandMessage>> commandInterceptors(Configuration config, Class<?> componentType, @Nullable String componentName) Returns the list ofCommandMessage-specificMessageHandlerInterceptorsregistered in this registry for acomponentTypeandcomponentName.voiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.List<MessageHandlerInterceptor<? super EventMessage>> eventInterceptors(Configuration config, Class<?> componentType, @Nullable String componentName) Returns the list ofEventMessage-specificMessageHandlerInterceptorsregistered in this registry for acomponentTypeandcomponentName.List<MessageHandlerInterceptor<? super QueryMessage>> queryInterceptors(Configuration config, Class<?> componentType, @Nullable String componentName) Returns the list ofQueryMessage-specificMessageHandlerInterceptorsregistered in this registry for acomponentTypeandcomponentName.registerCommandInterceptor(ComponentBuilder<MessageHandlerInterceptor<? super CommandMessage>> interceptorBuilder) Registers the giveninterceptorBuilderfor aCommandMessageMessageHandlerInterceptorfor all command handling infrastructure components.registerCommandInterceptor(HandlerInterceptorFactory<? super CommandMessage> interceptorFactory) Registers the given component-awareinterceptorFactoryfor aCommandMessageMessageHandlerInterceptorfor all command handling infrastructure components.registerEventInterceptor(ComponentBuilder<MessageHandlerInterceptor<? super EventMessage>> interceptorBuilder) Registers the giveninterceptorBuilderfor aEventMessageMessageHandlerInterceptorfor all event handling infrastructure components.registerEventInterceptor(HandlerInterceptorFactory<? super EventMessage> interceptorFactory) Registers the given component-awareinterceptorFactoryfor aEventMessageMessageHandlerInterceptorfor all event handling infrastructure components.registerInterceptor(ComponentBuilder<MessageHandlerInterceptor<Message>> interceptorBuilder) Registers the giveninterceptorBuilderconstructing a genericMessageMessageHandlerInterceptorfor all handling infrastructure components.registerInterceptor(HandlerInterceptorFactory<Message> interceptorFactory) Registers the given component-awareinterceptorFactoryconstructing a genericMessageMessageHandlerInterceptorfor all handling infrastructure components.registerQueryInterceptor(ComponentBuilder<MessageHandlerInterceptor<? super QueryMessage>> interceptorBuilder) Registers the giveninterceptorBuilderfor aQueryMessageMessageHandlerInterceptorfor all query handling infrastructure componentsregisterQueryInterceptor(HandlerInterceptorFactory<? super QueryMessage> interceptorFactory) Registers the given component-awareinterceptorFactoryfor aQueryMessageMessageHandlerInterceptorfor all query handling infrastructure components.
-
Constructor Details
-
DefaultHandlerInterceptorRegistry
public DefaultHandlerInterceptorRegistry()
-
-
Method Details
-
registerInterceptor
public HandlerInterceptorRegistry registerInterceptor(ComponentBuilder<MessageHandlerInterceptor<Message>> interceptorBuilder) Description copied from interface:HandlerInterceptorRegistryRegisters the giveninterceptorBuilderconstructing a genericMessageMessageHandlerInterceptorfor all handling infrastructure components.Registering an interceptor per a
ComponentBuilderensures the interceptor is only build once.- Specified by:
registerInterceptorin interfaceHandlerInterceptorRegistry- Parameters:
interceptorBuilder- the genericMessageMessageHandlerInterceptorbuilder to register- Returns:
- this
InterceptorRegistry, for fluent interfacing
-
registerInterceptor
public HandlerInterceptorRegistry registerInterceptor(HandlerInterceptorFactory<Message> interceptorFactory) Description copied from interface:HandlerInterceptorRegistryRegisters the given component-awareinterceptorFactoryconstructing a genericMessageMessageHandlerInterceptorfor all handling infrastructure components.The factory will receive the component type and name when the interceptor is retrieved allowing for component-specific customization of the interceptor. Registering an interceptor per a
HandlerInterceptorFactoryenforces construction of the interceptor for every invocation of the factory, ensuring uniqueness per given type and name. If the interceptor will be identical regardless of the given type or name, please useHandlerInterceptorRegistry.registerInterceptor(ComponentBuilder)instead.- Specified by:
registerInterceptorin interfaceHandlerInterceptorRegistry- Parameters:
interceptorFactory- the genericMessageMessageHandlerInterceptorfactory to register- Returns:
- this
InterceptorRegistry, for fluent interfacing
-
registerCommandInterceptor
public HandlerInterceptorRegistry registerCommandInterceptor(ComponentBuilder<MessageHandlerInterceptor<? super CommandMessage>> interceptorBuilder) Description copied from interface:HandlerInterceptorRegistryRegisters the giveninterceptorBuilderfor aCommandMessageMessageHandlerInterceptorfor all command handling infrastructure components.Registering an interceptor per a
ComponentBuilderensures the interceptor is only built once.- Specified by:
registerCommandInterceptorin interfaceHandlerInterceptorRegistry- Parameters:
interceptorBuilder- theCommandMessage-specificMessageHandlerInterceptorbuilder to register- Returns:
- this
InterceptorRegistry, for fluent interfacing
-
registerCommandInterceptor
public HandlerInterceptorRegistry registerCommandInterceptor(HandlerInterceptorFactory<? super CommandMessage> interceptorFactory) Description copied from interface:HandlerInterceptorRegistryRegisters the given component-awareinterceptorFactoryfor aCommandMessageMessageHandlerInterceptorfor all command handling infrastructure components.The factory will receive the component type and name when the interceptor is retrieved allowing for component-specific customization of the interceptor. Registering an interceptor per a
HandlerInterceptorFactoryenforces construction of the interceptor for every invocation of the factory, ensuring uniqueness per given typa and name. If the interceptor will be identical regardless of the given type or name, please useHandlerInterceptorRegistry.registerCommandInterceptor(ComponentBuilder)instead.- Specified by:
registerCommandInterceptorin interfaceHandlerInterceptorRegistry- Parameters:
interceptorFactory- theCommandMessage-specificMessageHandlerInterceptorfactory to register- Returns:
- this
InterceptorRegistry, for fluent interfacing
-
registerEventInterceptor
public HandlerInterceptorRegistry registerEventInterceptor(ComponentBuilder<MessageHandlerInterceptor<? super EventMessage>> interceptorBuilder) Description copied from interface:HandlerInterceptorRegistryRegisters the giveninterceptorBuilderfor aEventMessageMessageHandlerInterceptorfor all event handling infrastructure components.Registering an interceptor per a
ComponentBuilderensures the interceptor is only build once.- Specified by:
registerEventInterceptorin interfaceHandlerInterceptorRegistry- Parameters:
interceptorBuilder- theEventMessage-specificMessageHandlerInterceptorbuilder to register- Returns:
- this
InterceptorRegistry, for fluent interfacing
-
registerEventInterceptor
public HandlerInterceptorRegistry registerEventInterceptor(HandlerInterceptorFactory<? super EventMessage> interceptorFactory) Description copied from interface:HandlerInterceptorRegistryRegisters the given component-awareinterceptorFactoryfor aEventMessageMessageHandlerInterceptorfor all event handling infrastructure components.The factory will receive the component type and name when the interceptor is retrieved allowing for component-specific customization of the interceptor. Registering an interceptor per a
HandlerInterceptorFactoryenforces construction of the interceptor for every invocation of the factory, ensuring uniqueness per given typa and name. If the interceptor will be identical regardless of the given type or name, please useHandlerInterceptorRegistry.registerEventInterceptor(ComponentBuilder)instead.- Specified by:
registerEventInterceptorin interfaceHandlerInterceptorRegistry- Parameters:
interceptorFactory- theEventMessage-specificMessageHandlerInterceptorfactory to register- Returns:
- this
InterceptorRegistry, for fluent interfacing
-
registerQueryInterceptor
public HandlerInterceptorRegistry registerQueryInterceptor(ComponentBuilder<MessageHandlerInterceptor<? super QueryMessage>> interceptorBuilder) Description copied from interface:HandlerInterceptorRegistryRegisters the giveninterceptorBuilderfor aQueryMessageMessageHandlerInterceptorfor all query handling infrastructure componentsRegistering an interceptor per a
ComponentBuilderensures the interceptor is only build once.- Specified by:
registerQueryInterceptorin interfaceHandlerInterceptorRegistry- Parameters:
interceptorBuilder- theQueryMessage-specificMessageHandlerInterceptorbuilder to register- Returns:
- this
InterceptorRegistry, for fluent interfacing
-
registerQueryInterceptor
public HandlerInterceptorRegistry registerQueryInterceptor(HandlerInterceptorFactory<? super QueryMessage> interceptorFactory) Description copied from interface:HandlerInterceptorRegistryRegisters the given component-awareinterceptorFactoryfor aQueryMessageMessageHandlerInterceptorfor all query handling infrastructure components.The factory will receive the component type and name when the interceptor is retrieved allowing for component-specific customization of the interceptor. Registering an interceptor per a
HandlerInterceptorFactoryenforces construction of the interceptor for every invocation of the factory, ensuring uniqueness per given typa and name. If the interceptor will be identical regardless of the given type or name, please useHandlerInterceptorRegistry.registerQueryInterceptor(ComponentBuilder)instead.- Specified by:
registerQueryInterceptorin interfaceHandlerInterceptorRegistry- Parameters:
interceptorFactory- theQueryMessage-specificMessageHandlerInterceptorfactory to register- Returns:
- this
InterceptorRegistry, for fluent interfacing
-
commandInterceptors
public List<MessageHandlerInterceptor<? super CommandMessage>> commandInterceptors(Configuration config, Class<?> componentType, @Nullable String componentName) Description copied from interface:HandlerInterceptorRegistryReturns the list ofCommandMessage-specificMessageHandlerInterceptorsregistered in this registry for acomponentTypeandcomponentName.This collection contains generic
MessageMessageHandlerInterceptorsthat have beenregisteredwhen the generic builder returns an instance.- Specified by:
commandInterceptorsin interfaceHandlerInterceptorRegistry- Parameters:
config- the configuration to build allCommandMessage-specificMessageHandlerInterceptorswithcomponentType- the type of the component being intercepted to retrieve a handler interceptor forcomponentName- the name of the component being intercepted to retrieve a handler interceptor for- Returns:
- the list of
CommandMessage-specificMessageHandlerInterceptors
-
eventInterceptors
public List<MessageHandlerInterceptor<? super EventMessage>> eventInterceptors(Configuration config, Class<?> componentType, @Nullable String componentName) Description copied from interface:HandlerInterceptorRegistryReturns the list ofEventMessage-specificMessageHandlerInterceptorsregistered in this registry for acomponentTypeandcomponentName.This collection contains generic
MessageMessageHandlerInterceptorsthat have beenregisteredwhen the generic builder returns an instance.- Specified by:
eventInterceptorsin interfaceHandlerInterceptorRegistry- Parameters:
config- the configuration to build allEventMessage-specificMessageHandlerInterceptorswithcomponentType- the type of the component being intercepted to retrieve a handler interceptor forcomponentName- the name of the component being intercepted to retrieve a handler interceptor for- Returns:
- the list of
EventMessage-specificMessageHandlerInterceptors
-
queryInterceptors
public List<MessageHandlerInterceptor<? super QueryMessage>> queryInterceptors(Configuration config, Class<?> componentType, @Nullable String componentName) Description copied from interface:HandlerInterceptorRegistryReturns the list ofQueryMessage-specificMessageHandlerInterceptorsregistered in this registry for acomponentTypeandcomponentName.This collection contains generic
MessageMessageHandlerInterceptorsthat have beenregisteredwhen the generic builder returns an instance.- Specified by:
queryInterceptorsin interfaceHandlerInterceptorRegistry- Parameters:
config- the configuration to build allQueryMessage-specificMessageHandlerInterceptorswithcomponentType- the type of the component being intercepted to retrieve a handler interceptor forcomponentName- the name of the component being intercepted to retrieve a handler interceptor for- Returns:
- the list of
QueryMessage-specificMessageHandlerInterceptors
-
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.
-