/** * Instantiate a {@link SimpleEventHandlerInvoker} based on the fields contained in the {@link Builder}. * <p> * Will assert that at least one {@link EventMessageHandler} is provided, and will throw an * {@link AxonConfigurationException} if this is not the case. * * @param builder the {@link Builder} used to instantiate a {@link SimpleEventHandlerInvoker} instance */ protected SimpleEventHandlerInvoker(Builder builder) { builder.validate(); this.eventHandlers = builder.eventHandlers; this.wrappedEventHandlers = eventHandlers.stream() .map(handler -> handler instanceof EventMessageHandler ? (EventMessageHandler) handler : builder.wrapEventMessageHandler(handler)) .collect(Collectors.toCollection(ArrayList::new)); this.sequencingPolicy = builder.sequencingPolicy; this.listenerInvocationErrorHandler = builder.listenerInvocationErrorHandler; }
/** * Instantiate a {@link SimpleEventHandlerInvoker} based on the fields contained in the {@link Builder}. * <p> * Will assert that at least one {@link EventMessageHandler} is provided, and will throw an * {@link AxonConfigurationException} if this is not the case. * * @param builder the {@link Builder} used to instantiate a {@link SimpleEventHandlerInvoker} instance */ protected SimpleEventHandlerInvoker(Builder builder) { builder.validate(); this.eventHandlers = builder.eventHandlers; this.wrappedEventHandlers = eventHandlers.stream() .map(handler -> handler instanceof EventMessageHandler ? (EventMessageHandler) handler : builder.wrapEventMessageHandler(handler)) .collect(Collectors.toCollection(ArrayList::new)); this.sequencingPolicy = builder.sequencingPolicy; this.listenerInvocationErrorHandler = builder.listenerInvocationErrorHandler; }