@Override public EventProcessingConfigurer registerTokenStore(String processingGroup, Function<Configuration, TokenStore> tokenStore) { this.tokenStore.put(processingGroup, new Component<>(() -> configuration, "tokenStore", tokenStore)); return this; }
@Override public EventProcessingConfigurer registerRollbackConfiguration(String name, Function<Configuration, RollbackConfiguration> rollbackConfigurationBuilder) { this.rollbackConfigurations.put(name, new Component<>(() -> configuration, "rollbackConfiguration", rollbackConfigurationBuilder)); return this; }
@Override public EventProcessingConfigurer registerTransactionManager(String name, Function<Configuration, TransactionManager> transactionManagerBuilder) { this.transactionManagers.put(name, new Component<>(() -> configuration, "transactionManager", transactionManagerBuilder)); return this; }
@Override public Configurer registerEventUpcaster(Function<Configuration, EventUpcaster> upcasterBuilder) { upcasters.add(new Component<>(config, "upcaster", upcasterBuilder)); return this; }
@Override public EventProcessingConfigurer registerErrorHandler(String eventProcessorName, Function<Configuration, ErrorHandler> errorHandlerBuilder) { this.errorHandlers.put(eventProcessorName, new Component<>(() -> configuration, "errorHandler", errorHandlerBuilder)); return this; }
@Override public EventProcessingConfigurer registerEventHandler( Function<Configuration, Object> eventHandlerBuilder) { this.eventHandlerBuilders.add(new Component<>(() -> configuration, "eventHandler", eventHandlerBuilder)); return this; }
@Override public EventProcessingConfigurer registerListenerInvocationErrorHandler(String processingGroup, Function<Configuration, ListenerInvocationErrorHandler> listenerInvocationErrorHandlerBuilder) { listenerInvocationErrorHandlers.put(processingGroup, new Component<>(() -> configuration, "listenerInvocationErrorHandler", listenerInvocationErrorHandlerBuilder)); return this; }
@Override public EventProcessingConfigurer registerSequencingPolicy(String processingGroup, Function<Configuration, SequencingPolicy<? super EventMessage<?>>> policyBuilder) { this.sequencingPolicies.put(processingGroup, new Component<>(() -> configuration, "sequencingPolicy", policyBuilder)); return this; }
@Override public <C> Configurer registerComponent(Class<C> componentType, Function<Configuration, ? extends C> componentBuilder) { components.put(componentType, new Component<>(config, componentType.getSimpleName(), componentBuilder)); return this; }
/** * Initialize the Configurer. */ protected DefaultConfigurer() { components.put(ParameterResolverFactory.class, new Component<>(config, "parameterResolverFactory", this::defaultParameterResolverFactory)); components.put(Serializer.class, new Component<>(config, "serializer", this::defaultSerializer)); components.put(CommandBus.class, new Component<>(config, "commandBus", this::defaultCommandBus)); components.put(EventBus.class, new Component<>(config, "eventBus", this::defaultEventBus)); components.put(EventStore.class, new Component<>(config, "eventStore", Configuration::eventStore)); components.put(CommandGateway.class, new Component<>(config, "commandGateway", this::defaultCommandGateway)); components.put(QueryBus.class, new Component<>(config, "queryBus", this::defaultQueryBus)); components.put( QueryUpdateEmitter.class, new Component<>(config, "queryUpdateEmitter", this::defaultQueryUpdateEmitter) ); components.put(QueryGateway.class, new Component<>(config, "queryGateway", this::defaultQueryGateway)); components.put(ResourceInjector.class, new Component<>(config, "resourceInjector", this::defaultResourceInjector)); components.put(DeadlineManager.class, new Component<>(config, "deadlineManager", this::defaultDeadlineManager)); components.put(EventUpcaster.class, upcasterChain); }
@Override public <T> T getComponent(Class<T> componentType, Supplier<T> defaultImpl) { return componentType.cast(components.computeIfAbsent( componentType, k -> new Component<>(config, componentType.getSimpleName(), c -> defaultImpl.get()) ).get()); }
@Override public void initialize(Configuration configuration) { this.configuration = configuration; eventProcessors.clear(); instanceSelectors.sort(comparing(InstanceProcessingGroupSelector::getPriority).reversed()); Map<String, List<Function<Configuration, EventHandlerInvoker>>> handlerInvokers = new HashMap<>(); registerSimpleEventHandlerInvokers(handlerInvokers); registerSagaManagers(handlerInvokers); handlerInvokers.forEach((processorName, invokers) -> { Component<EventProcessor> eventProcessorComponent = new Component<>(configuration, processorName, c -> buildEventProcessor(invokers, processorName)); eventProcessors.put(processorName, eventProcessorComponent); }); }
public EventProcessorInfoConfiguration( Function<Configuration, EventProcessingConfiguration> eventProcessingConfiguration, Function<Configuration, AxonServerConnectionManager> connectionManager, Function<Configuration, AxonServerConfiguration> axonServerConfiguration) { this.eventProcessingConfiguration = new Component<>(() -> config, "eventProcessingConfiguration", eventProcessingConfiguration); this.connectionManager = new Component<>(() -> config, "connectionManager", connectionManager); this.axonServerConfiguration = new Component<>(() -> config, "connectionManager", axonServerConfiguration); this.eventProcessorControlService = new Component<>(() -> config, "eventProcessorControlService", c -> new EventProcessorControlService( this.connectionManager.get(), new EventProcessorController( this.eventProcessingConfiguration.get()))); this.processorInfoSource = new Component<>(() -> config, "eventProcessorInfoSource", c -> { GrpcEventProcessorInfoSource infoSource = new GrpcEventProcessorInfoSource(this.eventProcessingConfiguration.get(), this.connectionManager.get()); return new ScheduledEventProcessorInfoSource( this.axonServerConfiguration.get().getProcessorsNotificationInitialDelay(), this.axonServerConfiguration.get().getProcessorsNotificationRate(), infoSource); }); }
String managerName = configurer.type.getSimpleName() + "Manager"; String repositoryName = configurer.type.getSimpleName() + "Repository"; store = new Component<>(configuration, "sagaStore", configurer.storeBuilder); Function<Configuration, SagaRepository<S>> repositoryBuilder = configurer.repositoryBuilder; if (repositoryBuilder == null) { .build(); repository = new Component<>(configuration, repositoryName, repositoryBuilder); }; manager = new Component<>(configuration, managerName, managerBuilder);
this.aggregate = aggregate; metaModel = new Component<>(() -> parent, "aggregateMetaModel<" + aggregate.getSimpleName() + ">", c -> c.getComponent( c.handlerDefinition(aggregate)) ).createModel(aggregate)); commandTargetResolver = new Component<>(() -> parent, name("commandTargetResolver"), c -> c.getComponent(CommandTargetResolver.class, AnnotationCommandTargetResolver::new)); snapshotTriggerDefinition = new Component<>(() -> parent, name("snapshotTriggerDefinition"), c -> NoSnapshotTriggerDefinition.INSTANCE); aggregateFactory = new Component<>(() -> parent, name("aggregateFactory"), c -> new GenericAggregateFactory<>(aggregate)); repository = new Component<>( () -> parent, "Repository<" + aggregate.getSimpleName() + ">", .build(); }); commandHandler = new Component<>(() -> parent, "aggregateCommandHandler<" + aggregate.getSimpleName() + ">", c -> AggregateAnnotationCommandHandler.<A>builder() .repository(repository.get())
@Override public Configurer registerEventUpcaster(Function<Configuration, EventUpcaster> upcasterBuilder) { upcasters.add(new Component<>(config, "upcaster", upcasterBuilder)); return this; }
@Override public Configurer registerEventUpcaster(Function<Configuration, EventUpcaster> upcasterBuilder) { upcasters.add(new Component<>(config, "upcaster", upcasterBuilder)); return this; }
@Override public EventProcessingConfigurer registerRollbackConfiguration(String name, Function<Configuration, RollbackConfiguration> rollbackConfigurationBuilder) { this.rollbackConfigurations.put(name, new Component<>(() -> configuration, "rollbackConfiguration", rollbackConfigurationBuilder)); return this; }
@Override public <C> Configurer registerComponent(Class<C> componentType, Function<Configuration, ? extends C> componentBuilder) { components.put(componentType, new Component<>(config, componentType.getSimpleName(), componentBuilder)); return this; }
@Override public <T> T getComponent(Class<T> componentType, Supplier<T> defaultImpl) { return componentType.cast(components.computeIfAbsent( componentType, k -> new Component<>(config, componentType.getSimpleName(), c -> defaultImpl.get()) ).get()); }