Interface ComponentDecorator<C,D>

Type Parameters:
C - The type of component to be decorated.
D - The type of decorated component.

public interface ComponentDecorator<C,D>
A functional interface describing how to decorate a component of type C.

Implementers of this interface can choose to wrap the delegate into a new instance of type C or to mutate the state of the delegate. The former solution is applicable for infrastructure components that support decorators. The latter form is suitable when customizing the configuration instance of an infrastructure component.

Since:
5.0.0
Author:
Steven van Beelen
  • Method Summary

    Modifier and Type
    Method
    Description
    decorate(Configuration config, String name, C delegate)
    Decorates the given delegate into a mutated or replaced instance of type D, which must be the same or a subclass of C.
  • Method Details

    • decorate

      D decorate(@Nonnull Configuration config, @Nullable String name, @Nonnull C delegate)
      Decorates the given delegate into a mutated or replaced instance of type D, which must be the same or a subclass of C.

      Decorating can roughly take two angles. One, it may choose to wrap the delegate into a new instance of type C. Second, it could mutate the state of the delegate.

      Option one would typically apply to infrastructure components that support decorators. An example of this is the

      invalid reference
      org.axonframework.commandhandling.CommandBus
      , which can for example be decorated with the
      invalid reference
      org.axonframework.commandhandling.tracing.TracingCommandBus
      .

      The latter form is suitable when customizing the configuration instance of an infrastructure component.

      Parameters:
      config - The configuration of this Axon application. Provided to support retrieval of other components for construction or mutation of the given delegate.
      name - The name of the component to be decorated.
      delegate - The delegate of type C to be decorated.
      Returns:
      A decorated component of type C, typically based on the given delegate.
      Throws:
      ClassCastException - When this decorator does not return a subclass of C.