/** * Sets the {@link MessageDispatchInterceptor}s which are invoked before dispatching a {@link CommandMessage} on * the {@link CommandBus}. Note that the given {@code dispatchInterceptors} are applied only on commands sent * through gateways that have been created using this factory. * * @param dispatchInterceptors an array of {@link MessageDispatchInterceptor}s which are invoked before * dispatching a {@link CommandMessage} on the {@link CommandBus} * @return the current Builder instance, for fluent interfacing */ public Builder dispatchInterceptors( MessageDispatchInterceptor<? super CommandMessage<?>>... dispatchInterceptors) { return dispatchInterceptors(Arrays.asList(dispatchInterceptors)); }
/** * Instantiate a {@link CommandGatewayFactory} based on the fields contained in the {@link Builder}. * <p> * Will assert that the {@link CommandBus} is not {@code null}, and will throw an * {@link AxonConfigurationException} if it is {@code null}. * * @param builder the {@link Builder} used to instantiate a {@link CommandGatewayFactory} instance */ protected CommandGatewayFactory(Builder builder) { builder.validate(); this.commandBus = builder.commandBus; this.retryScheduler = builder.retryScheduler; if (builder.dispatchInterceptors != null && !builder.dispatchInterceptors.isEmpty()) { this.dispatchInterceptors = new CopyOnWriteArrayList<>(builder.dispatchInterceptors); } else { this.dispatchInterceptors = new CopyOnWriteArrayList<>(); } this.commandCallbacks = new CopyOnWriteArrayList<>(); }
/** * Instantiate a {@link CommandGatewayFactory} based on the fields contained in the {@link Builder}. * <p> * Will assert that the {@link CommandBus} is not {@code null}, and will throw an * {@link AxonConfigurationException} if it is {@code null}. * * @param builder the {@link Builder} used to instantiate a {@link CommandGatewayFactory} instance */ protected CommandGatewayFactory(Builder builder) { builder.validate(); this.commandBus = builder.commandBus; this.retryScheduler = builder.retryScheduler; if (builder.dispatchInterceptors != null && !builder.dispatchInterceptors.isEmpty()) { this.dispatchInterceptors = new CopyOnWriteArrayList<>(builder.dispatchInterceptors); } else { this.dispatchInterceptors = new CopyOnWriteArrayList<>(); } this.commandCallbacks = new CopyOnWriteArrayList<>(); }
/** * Instantiate a Builder to be able to create a {@link CommandGatewayFactory}. * <p> * The {@link CommandBus} is a <b>hard requirements</b> and as such should be provided. * * @return a Builder to be able to create a {@link CommandGatewayFactory} */ public static Builder builder() { return new Builder(); }
/** * Sets the {@link MessageDispatchInterceptor}s which are invoked before dispatching a {@link CommandMessage} on * the {@link CommandBus}. Note that the given {@code dispatchInterceptors} are applied only on commands sent * through gateways that have been created using this factory. * * @param dispatchInterceptors an array of {@link MessageDispatchInterceptor}s which are invoked before * dispatching a {@link CommandMessage} on the {@link CommandBus} * @return the current Builder instance, for fluent interfacing */ public Builder dispatchInterceptors( MessageDispatchInterceptor<? super CommandMessage<?>>... dispatchInterceptors) { return dispatchInterceptors(Arrays.asList(dispatchInterceptors)); }
/** * Instantiate a Builder to be able to create a {@link CommandGatewayFactory}. * <p> * The {@link CommandBus} is a <b>hard requirements</b> and as such should be provided. * * @return a Builder to be able to create a {@link CommandGatewayFactory} */ public static Builder builder() { return new Builder(); }
@Override public Builder commandBus(CommandBus commandBus) { super.commandBus(commandBus); return this; }