Class ConfigurationExtensions

java.lang.Object
org.axonframework.common.configuration.ConfigurationExtensions
All Implemented Interfaces:
DescribableComponent

@Internal public class ConfigurationExtensions extends Object implements DescribableComponent
Internal helper that manages the lifecycle of ConfigurationExtension instances for an ExtensibleConfigurer parent configuration.

Extensions are created eagerly when extend(Class, Supplier) is called — the factory is invoked immediately and the resulting instance is stored. If extend() is called again for the same type, the previous instance is replaced. extension(Class) returns the stored instance, or null if no extension of that type has been registered.

This class is not part of the public API. It exists purely to encapsulate extension management so that ExtensibleConfigurer implementations can delegate to it without duplicating logic.

Since:
5.1.0
Author:
Mateusz Nowak
  • Constructor Details

    • ConfigurationExtensions

      public ConfigurationExtensions(ExtensibleConfigurer parentConfigurer)
      Constructs a new ConfigurationExtensions for the given parentConfigurer.
      Parameters:
      parentConfigurer - the parent configuration that owns these extensions
  • Method Details

    • extension

      public <T extends ConfigurationExtension<?>> @Nullable T extension(Class<T> extensionType)
      Returns the extension of the given extensionType, or null if no extension of that type has been registered via extend(Class, Supplier).
      Type Parameters:
      T - the extension type
      Parameters:
      extensionType - the extension class
      Returns:
      the extension instance, or null if not registered
    • extend

      public <T extends ConfigurationExtension<?>> ExtensibleConfigurer extend(Class<T> extensionType, Supplier<T> factory)
      Registers an extension by invoking the given factory immediately and storing the result.

      If an extension of the same type was previously registered, it is replaced — the factory always overrides the previous instance.

      Type Parameters:
      T - the extension type
      Parameters:
      extensionType - the extension class
      factory - a supplier that returns a configured extension
      Returns:
      the parent configurer, for fluent chaining
    • validate

      public void validate()
      Validates all registered extensions by calling ConfigurationExtension.validate() on each.
      Throws:
      AxonConfigurationException - if any extension's validation fails
    • extendFrom

      public void extendFrom(ConfigurationExtensions source)
      Copies extensions from the given source that are not already present in this. Existing extensions on this are preserved.
      Parameters:
      source - The source to copy missing extensions from.
    • describeTo

      public void describeTo(ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods 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 DescribableComponent implementation 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 the describeTo method, 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:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.