Interface ComponentDecorator<C,D>
- Type Parameters:
C- The type of component to be decorated.D- The type of decorated component.
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 TypeMethodDescriptiondecorate(Configuration config, String name, C delegate) Decorates the givendelegateinto a mutated or replaced instance of typeD, which must be the same or a subclass ofC.
-
Method Details
-
decorate
Decorates the givendelegateinto a mutated or replaced instance of typeD, which must be the same or a subclass ofC.Decorating can roughly take two angles. One, it may choose to wrap the
delegateinto a new instance of typeC. Second, it could mutate the state of thedelegate.Option one would typically apply to infrastructure components that support decorators. An example of this is the
, which can for example be decorated with theinvalid reference
org.axonframework.commandhandling.CommandBus.invalid reference
org.axonframework.commandhandling.tracing.TracingCommandBusThe 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 othercomponentsfor construction or mutation of the givendelegate.name- The name of the component to be decorated.delegate- The delegate of typeCto be decorated.- Returns:
- A decorated component of type
C, typically based on the givendelegate. - Throws:
ClassCastException- When this decorator does not return a subclass ofC.
-