Class DefaultMessageMonitorRegistry
- All Implemented Interfaces:
DescribableComponent,MessageMonitorRegistry
DefaultMessageMonitorRegistry is a default implementation of the MessageMonitorRegistry interface
responsible for managing and providing components of MessageMonitor for various message types such as
CommandMessage, EventMessage, and QueryMessage.
This class allows registering monitor builders and factories for each message type and resolves those monitors into
properly initialized components when required. If no custom monitors are registered for a specific type, default
implementations like NoOpMessageMonitor are returned to ensure no operational interruptions.
When using the ComponentBuilder registration methods, this registry will internally maintain a separate lists
of ComponentDefinition to store the registered monitor builders for command, event, and query messages. It
also supports registering a generic MessageMonitor for Message, in which case a specialized
MessageMonitor is created for each of the supported subtypes.
- Since:
- 5.0.0
- Author:
- Jan Galinski
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionMessageMonitor<? super CommandMessage> commandMonitor(Configuration config, Class<?> componentType, @Nullable String componentName) Retrieves aMessageMonitordedicated for monitoringCommandMessageprocessing for a specificcomponentTypeandcomponentName.voiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.MessageMonitor<? super EventMessage> eventMonitor(Configuration config, Class<?> componentType, @Nullable String componentName) Retrieves aMessageMonitorspecifically designed to monitor the processing ofEventMessageinstances for a specificcomponentTypeandcomponentName.MessageMonitor<? super QueryMessage> queryMonitor(Configuration config, Class<?> componentType, @Nullable String componentName) Retrieves aMessageMonitorfor monitoring the processing ofQueryMessageinstances for a specificcomponentTypeandcomponentName.registerCommandMonitor(ComponentBuilder<MessageMonitor<? super CommandMessage>> monitorBuilder) Registers aMessageMonitorspecifically for monitoring the processing ofCommandMessageinstances.registerCommandMonitor(MessageMonitorFactory<? super CommandMessage> monitorFactory) Registers a component-awareMessageMonitorspecifically for monitoring the processing ofCommandMessageinstances using the givenmonitorFactory.registerEventMonitor(ComponentBuilder<MessageMonitor<? super EventMessage>> monitorBuilder) Registers aMessageMonitorspecific forEventMessagetypes using the supplied monitor builder.registerEventMonitor(MessageMonitorFactory<? super EventMessage> monitorFactory) Registers a component-awareMessageMonitorspecifically for monitoring the processing ofEventMessageinstances using the givenmonitorFactory.registerMonitor(ComponentBuilder<MessageMonitor<Message>> monitorBuilder) Registers aMessageMonitorfor genericMessagetypes using the supplied monitor builder.registerMonitor(MessageMonitorFactory<Message> monitorFactory) Registers a component-awareMessageMonitorfor genericMessagetypes using the givenmonitorFactory.registerQueryMonitor(ComponentBuilder<MessageMonitor<? super QueryMessage>> monitorBuilder) registerQueryMonitor(MessageMonitorFactory<? super QueryMessage> monitorFactory) Registers a component-awareMessageMonitorspecifically for monitoring the processing ofQueryMessageinstances using the givenmonitorFactory.registerSubscriptionQueryUpdateMonitor(ComponentBuilder<MessageMonitor<? super SubscriptionQueryUpdateMessage>> monitorBuilder) Registers aMessageMonitorspecifically forSubscriptionQueryUpdateMessagetypes using the providedComponentBuilder.registerSubscriptionQueryUpdateMonitor(MessageMonitorFactory<? super SubscriptionQueryUpdateMessage> monitorFactory) Registers a component-awareMessageMonitorspecifically for monitoring the processing ofSubscriptionQueryUpdateMessageinstances using the givenmonitorFactory.subscriptionQueryUpdateMonitor(Configuration config, Class<?> componentType, @Nullable String componentName) Retrieves aMessageMonitorfor monitoring the processing ofSubscriptionQueryUpdateMessageinstances for a specificcomponentTypeandcomponentName.
-
Constructor Details
-
DefaultMessageMonitorRegistry
public DefaultMessageMonitorRegistry()
-
-
Method Details
-
registerMonitor
public MessageMonitorRegistry registerMonitor(ComponentBuilder<MessageMonitor<Message>> monitorBuilder) Description copied from interface:MessageMonitorRegistryRegisters aMessageMonitorfor genericMessagetypes using the supplied monitor builder.Registering a monitor per a
ComponentBuilderensures the monitor is only built once.- Specified by:
registerMonitorin interfaceMessageMonitorRegistry- Parameters:
monitorBuilder- theComponentBuilderresponsible for creating theMessageMonitorinstance for genericMessagetypes- Returns:
- the updated
MessageMonitorRegistryinstance for fluent configuration
-
registerMonitor
Description copied from interface:MessageMonitorRegistryRegisters a component-awareMessageMonitorfor genericMessagetypes using the givenmonitorFactory.The factory will receive the component type and name when the monitor is retrieved allowing for omponent-specific customization of the monitor. Registering a monitor per a
MessageMonitorFactoryenforces construction of the monitor for every invocation of the factory, ensuring uniqueness per given type and name. If the monitor will be identical regardless of the given type or name, please useMessageMonitorRegistry.registerMonitor(ComponentBuilder)instead.- Specified by:
registerMonitorin interfaceMessageMonitorRegistry- Parameters:
monitorFactory- theMessageMonitorFactoryresponsible for creating theMessageMonitorinstance for genericMessagetypes- Returns:
- the updated
MessageMonitorRegistryinstance for fluent configuration
-
registerCommandMonitor
public MessageMonitorRegistry registerCommandMonitor(ComponentBuilder<MessageMonitor<? super CommandMessage>> monitorBuilder) Description copied from interface:MessageMonitorRegistryRegisters aMessageMonitorspecifically for monitoring the processing ofCommandMessageinstances.Registering a monitor per a
ComponentBuilderensures the monitor is only build once.- Specified by:
registerCommandMonitorin interfaceMessageMonitorRegistry- Parameters:
monitorBuilder- theComponentBuilderused to create theMessageMonitorinstance forCommandMessagetypes- Returns:
- the updated
MessageMonitorRegistryinstance, allowing for a fluent configuration approach
-
registerCommandMonitor
public MessageMonitorRegistry registerCommandMonitor(MessageMonitorFactory<? super CommandMessage> monitorFactory) Description copied from interface:MessageMonitorRegistryRegisters a component-awareMessageMonitorspecifically for monitoring the processing ofCommandMessageinstances using the givenmonitorFactory.The factory will receive the component type and name when the monitor is retrieved allowing for component-specific customization of the monitor. Registering a monitor per a
MessageMonitorFactoryenforces construction of the monitor for every invocation of the factory, ensuring uniqueness per given type and name. If the monitor will be identical regardless of the given type or name, please useMessageMonitorRegistry.registerCommandMonitor(ComponentBuilder)instead.- Specified by:
registerCommandMonitorin interfaceMessageMonitorRegistry- Parameters:
monitorFactory- theMessageMonitorFactoryused to create theMessageMonitorinstance forCommandMessagetypes- Returns:
- the updated
MessageMonitorRegistryinstance, allowing for a fluent configuration approach
-
registerEventMonitor
public MessageMonitorRegistry registerEventMonitor(ComponentBuilder<MessageMonitor<? super EventMessage>> monitorBuilder) Description copied from interface:MessageMonitorRegistryRegisters aMessageMonitorspecific forEventMessagetypes using the supplied monitor builder.Registering a monitor per a
ComponentBuilderensures the monitor is only build once.- Specified by:
registerEventMonitorin interfaceMessageMonitorRegistry- Parameters:
monitorBuilder- theComponentBuilderresponsible for creating theMessageMonitorinstance forEventMessagetypes- Returns:
- the updated
MessageMonitorRegistryinstance, allowing for a fluent configuration approach
-
registerEventMonitor
public MessageMonitorRegistry registerEventMonitor(MessageMonitorFactory<? super EventMessage> monitorFactory) Description copied from interface:MessageMonitorRegistryRegisters a component-awareMessageMonitorspecifically for monitoring the processing ofEventMessageinstances using the givenmonitorFactory.The factory will receive the component type and name when the monitor is retrieved allowing for component-specific customization of the monitor. Registering a monitor per a
MessageMonitorFactoryenforces construction of the monitor for every invocation of the factory, ensuring uniqueness per given type and name. If the monitor will be identical regardless of the given type or name, please useMessageMonitorRegistry.registerEventMonitor(ComponentBuilder)instead.- Specified by:
registerEventMonitorin interfaceMessageMonitorRegistry- Parameters:
monitorFactory- theMessageMonitorFactoryresponsible for creating theMessageMonitorinstance forEventMessagetypes- Returns:
- the updated
MessageMonitorRegistryinstance, allowing for a fluent configuration approach
-
registerQueryMonitor
public MessageMonitorRegistry registerQueryMonitor(ComponentBuilder<MessageMonitor<? super QueryMessage>> monitorBuilder) Description copied from interface:MessageMonitorRegistryRegisters aMessageMonitorspecifically forQueryMessagetypes using the providedComponentBuilder.Registering a monitor per a
ComponentBuilderensures the monitor is only build once.- Specified by:
registerQueryMonitorin interfaceMessageMonitorRegistry- Parameters:
monitorBuilder- theComponentBuilderresponsible for creating theMessageMonitorforQueryMessagetypes- Returns:
- the updated
MessageMonitorRegistryinstance, allowing for a fluent configuration approach
-
registerQueryMonitor
public MessageMonitorRegistry registerQueryMonitor(MessageMonitorFactory<? super QueryMessage> monitorFactory) Description copied from interface:MessageMonitorRegistryRegisters a component-awareMessageMonitorspecifically for monitoring the processing ofQueryMessageinstances using the givenmonitorFactory.The factory will receive the component type and name when the monitor is retrieved allowing for component-specific customization of the monitor. Registering a monitor per a
MessageMonitorFactoryenforces construction of the monitor for every invocation of the factory, ensuring uniqueness per given type and name. If the monitor will be identical regardless of the given type or name, please useMessageMonitorRegistry.registerQueryMonitor(ComponentBuilder)instead.- Specified by:
registerQueryMonitorin interfaceMessageMonitorRegistry- Parameters:
monitorFactory- theMessageMonitorFactoryresponsible for creating theMessageMonitorforQueryMessagetypes- Returns:
- the updated
MessageMonitorRegistryinstance, allowing for a fluent configuration approach
-
registerSubscriptionQueryUpdateMonitor
public MessageMonitorRegistry registerSubscriptionQueryUpdateMonitor(ComponentBuilder<MessageMonitor<? super SubscriptionQueryUpdateMessage>> monitorBuilder) Description copied from interface:MessageMonitorRegistryRegisters aMessageMonitorspecifically forSubscriptionQueryUpdateMessagetypes using the providedComponentBuilder.Registering a monitor per a
ComponentBuilderensures the monitor is only build once.- Specified by:
registerSubscriptionQueryUpdateMonitorin interfaceMessageMonitorRegistry- Parameters:
monitorBuilder- theComponentBuilderresponsible for creating theMessageMonitorforSubscriptionQueryUpdateMessagetypes- Returns:
- the updated
MessageMonitorRegistryinstance, allowing for a fluent configuration approach
-
registerSubscriptionQueryUpdateMonitor
public MessageMonitorRegistry registerSubscriptionQueryUpdateMonitor(MessageMonitorFactory<? super SubscriptionQueryUpdateMessage> monitorFactory) Description copied from interface:MessageMonitorRegistryRegisters a component-awareMessageMonitorspecifically for monitoring the processing ofSubscriptionQueryUpdateMessageinstances using the givenmonitorFactory.The factory will receive the component type and name when the monitor is retrieved allowing for component-specific customization of the monitor. Registering a monitor per a
MessageMonitorFactoryenforces construction of the monitor for every invocation of the factory, ensuring uniqueness per given type and name. If the monitor will be identical regardless of the given type or name, please useMessageMonitorRegistry.registerSubscriptionQueryUpdateMonitor(ComponentBuilder)instead.- Specified by:
registerSubscriptionQueryUpdateMonitorin interfaceMessageMonitorRegistry- Parameters:
monitorFactory- theMessageMonitorFactoryresponsible for creating theMessageMonitorforSubscriptionQueryUpdateMessagetypes- Returns:
- the updated
MessageMonitorRegistryinstance, allowing for a fluent configuration approach
-
commandMonitor
public MessageMonitor<? super CommandMessage> commandMonitor(Configuration config, Class<?> componentType, @Nullable String componentName) Description copied from interface:MessageMonitorRegistryRetrieves aMessageMonitordedicated for monitoringCommandMessageprocessing for a specificcomponentTypeandcomponentName.The returned monitor contains generic
MessageMessageMonitorsthat have beenregisteredwhen the generic builder/factory returns an instance.- Specified by:
commandMonitorin interfaceMessageMonitorRegistry- Parameters:
config- theConfigurationinstance used to create theMessageMonitorinstancescomponentType- the type of the component to retrieve a monitor forcomponentName- the name of the component to retrieve a monitor for- Returns:
MultiMessageMonitorcomposed of all registeredMessageMonitors, orNoOpMessageMonitor
-
eventMonitor
public MessageMonitor<? super EventMessage> eventMonitor(Configuration config, Class<?> componentType, @Nullable String componentName) Description copied from interface:MessageMonitorRegistryRetrieves aMessageMonitorspecifically designed to monitor the processing ofEventMessageinstances for a specificcomponentTypeandcomponentName.The returned monitor contains generic
MessageMessageMonitorsthat have beenregisteredwhen the generic builder/factory returns an instance.- Specified by:
eventMonitorin interfaceMessageMonitorRegistry- Parameters:
config- theConfigurationinstance used to create or retrieve theMessageMonitorinstancescomponentType- the type of the component to retrieve a monitor forcomponentName- the name of the component to retrieve a monitor for- Returns:
MultiMessageMonitorcomposed of all registeredMessageMonitors, orNoOpMessageMonitor
-
queryMonitor
public MessageMonitor<? super QueryMessage> queryMonitor(Configuration config, Class<?> componentType, @Nullable String componentName) Description copied from interface:MessageMonitorRegistryRetrieves aMessageMonitorfor monitoring the processing ofQueryMessageinstances for a specificcomponentTypeandcomponentName.The returned monitor contains generic
MessageMessageMonitorsthat have beenregisteredwhen the generic builder/factory returns an instance.- Specified by:
queryMonitorin interfaceMessageMonitorRegistry- Parameters:
config- theConfigurationused to create or retrieve theMessageMonitorforQueryMessagetypescomponentType- the type of the component to retrieve a monitor forcomponentName- the name of the component to retrieve a monitor for- Returns:
MultiMessageMonitorcomposed of all registeredMessageMonitors, orNoOpMessageMonitor
-
subscriptionQueryUpdateMonitor
public MessageMonitor<? super SubscriptionQueryUpdateMessage> subscriptionQueryUpdateMonitor(Configuration config, Class<?> componentType, @Nullable String componentName) Description copied from interface:MessageMonitorRegistryRetrieves aMessageMonitorfor monitoring the processing ofSubscriptionQueryUpdateMessageinstances for a specificcomponentTypeandcomponentName.The returned monitor contains generic
MessageMessageMonitorsthat have beenregisteredwhen the generic builder/factory returns an instance.- Specified by:
subscriptionQueryUpdateMonitorin interfaceMessageMonitorRegistry- Parameters:
config- theConfigurationused to create or retrieve theMessageMonitorforSubscriptionQueryUpdateMessagetypescomponentType- the type of the component to retrieve a monitor forcomponentName- the name of the component to retrieve a monitor for- Returns:
MultiMessageMonitorcomposed of all registeredMessageMonitors, orNoOpMessageMonitor
-
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.
-