Class EventExternalizationConfiguration.Router
java.lang.Object
org.springframework.modulith.events.EventExternalizationConfiguration.Router
- Enclosing interface:
- EventExternalizationConfiguration
API to define the event routing.
- Since:
- 1.1
- Author:
- Oliver Drotbohm
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a newEventExternalizationConfiguration.Routerfor the given selector filter.Router(Predicate<Object> filter, Function<Object, Object> mapper, Function<Object, RoutingTarget> router) Creates a newEventExternalizationConfiguration.Routerfor the given selectorPredicateand mapper and routerFunctions.
- 
Method SummaryModifier and TypeMethodDescriptionbuild()Creates a newEventExternalizationConfigurationrefelcting the current configuration.Registers a type-specific mapping function.Registers a new mappingFunctionreplacing the old one entirely.route(Class<T> type, Function<T, RoutingTarget> router) Registers a router function for the events of the given specific type.routeAll(Function<Object, RoutingTarget> router) Routes all events based on the given function.routeAllByType(Function<Class<?>, RoutingTarget> router) Routes all messages based on the event type only.Registers aBiFunctionto resolve the key for aRoutingTargetbased on the event instance.Configures the routing to rather use the mapping result rather than the original event instance.routeOptional(Function<Object, Optional<RoutingTarget>> router) Routes by extracting anOptionalroute from the event.routeOptionalByType(Function<Class<?>, Optional<RoutingTarget>> router) Routes by extracting anOptionalroute from the event type.
- 
Constructor Details- 
RouterRouter(Predicate<Object> filter, Function<Object, Object> mapper, Function<Object, RoutingTarget> router) Creates a newEventExternalizationConfiguration.Routerfor the given selectorPredicateand mapper and routerFunctions.- Parameters:
- filter- must not be null.
- mapper- must not be null.
- router- must not be null.
 
- 
RouterCreates a newEventExternalizationConfiguration.Routerfor the given selector filter.- Parameters:
- filter- must not be null.
 
 
- 
- 
Method Details- 
mappingRegisters a new mappingFunctionreplacing the old one entirely.- Parameters:
- mapper- must not be null.
- Returns:
- will never be null.
- See Also:
 
- 
mappingpublic <T> EventExternalizationConfiguration.Router mapping(Class<T> type, Function<T, Object> mapper) Registers a type-specific mapping function. Events not matching that type will still fall back to the global mapping function defined.- Type Parameters:
- T- the type to handle.
- Parameters:
- type- the type to handle, must not be null.
- mapper- the mapping function, must not be null.
- Returns:
- will never be null.
- See Also:
 
- 
routeMappedConfigures the routing to rather use the mapping result rather than the original event instance.- Returns:
- will never be null.
 
- 
routeAllRoutes all events based on the given function.- Parameters:
- router- must not be null.
- Returns:
- will never be null.
 
- 
routepublic <T> EventExternalizationConfiguration.Router route(Class<T> type, Function<T, RoutingTarget> router) Registers a router function for the events of the given specific type.- Type Parameters:
- T- the type to handle
- Parameters:
- type- must not be null.
- router- must not be null.
- Returns:
- will never be null.
 
- 
routeKeypublic <T> EventExternalizationConfiguration.Router routeKey(Class<T> type, Function<T, String> extractor) Registers aBiFunctionto resolve the key for aRoutingTargetbased on the event instance. The actual target will have been resolved through the currently configured, global router. To dynamically define full, type-specific resolution of aRoutingTarget, seeroute(Class, Function).- Type Parameters:
- T- the type to handle.
- Parameters:
- type- the type to configure the key extraction for, must not be null.
- extractor- the key extractor, must not be null.
- Returns:
- will never be null.
- See Also:
 
- 
routeOptionalpublic EventExternalizationConfiguration routeOptional(Function<Object, Optional<RoutingTarget>> router) Routes by extracting anOptionalroute from the event. IfOptional.empty()is returned by the function, we will fall back to the configured default routing.- Parameters:
- router- must not be null.
- Returns:
- will never be null.
 
- 
routeOptionalByTypepublic EventExternalizationConfiguration routeOptionalByType(Function<Class<?>, Optional<RoutingTarget>> router) Routes by extracting anOptionalroute from the event type. IfOptional.empty()is returned by the function, we will fall back to the configured general routing.- Parameters:
- router- must not be null.
- Returns:
- will never be null.
 
- 
routeAllByTypepublic EventExternalizationConfiguration.Router routeAllByType(Function<Class<?>, RoutingTarget> router) Routes all messages based on the event type only.- Parameters:
- router- must not be null.
- Returns:
- will never be null.
 
- 
buildCreates a newEventExternalizationConfigurationrefelcting the current configuration.- Returns:
- will never be null.
 
 
-