Class LazyInitializedComponentDefinition<C,A extends C>

java.lang.Object
org.axonframework.common.configuration.AbstractComponent<C,A>
org.axonframework.common.configuration.LazyInitializedComponentDefinition<C,A>
Type Parameters:
C - The declared type of the component.
A - The actual (runtime) type of the component.
All Implemented Interfaces:
Component<C>, ComponentDefinition<C>, ComponentDefinition.ComponentCreator<C>, DescribableComponent

@Internal public class LazyInitializedComponentDefinition<C,A extends C> extends AbstractComponent<C,A>
Implementation of Component and ComponentDefinition that instantiates a component using a configured builder.

For internal use only. Instead, use static methods on ComponentDefinition to instantiate definitions.

Since:
5.0.0
Author:
Allard Buijze
  • Constructor Details

    • LazyInitializedComponentDefinition

      public LazyInitializedComponentDefinition(@Nonnull Component.Identifier<C> identifier, @Nonnull ComponentBuilder<A> builder)
      Create the definition for a component with given identifier and given instance.
      Parameters:
      identifier - The identifier of the component.
      builder - The function used to create an instance of this component.
  • Method Details

    • doResolve

      public A doResolve(@Nonnull Configuration configuration)
    • isInstantiated

      public boolean isInstantiated()
      Description copied from interface: Component
      Indicates whether the component has been resolved.

      When true, any subsequent call to Component.resolve(Configuration) will return that same instance.

      Returns:
      true if the component has been instantiated, otherwise false.
    • describeTo

      public void describeTo(@Nonnull 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
      Overrides:
      describeTo in class AbstractComponent<C,A extends C>
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.