@Override public <T> T getComponent(Class<T> componentType, Supplier<T> defaultImpl) { return config.getComponent(componentType, defaultImpl); }
/** * Retrieves the Event Bus defined in this Configuration. * * @return the Event Bus defined in this Configuration */ default EventBus eventBus() { return getComponent(EventBus.class); }
/** * Returns the Query Update Emitter in this Configuration. Note that this Configuration should be started (see * {@link #start()} before emitting updates over Query Update Emitter. * * @return the QueryUpdateEmitter defined in this configuration */ default QueryUpdateEmitter queryUpdateEmitter() { return getComponent(QueryUpdateEmitter.class); }
/** * Returns the Query Gateway defined in this Configuration. Note that this Configuration should be started (see * {@link #start()}) before sending Queries using this Query Gateway. * * @return the QueryGateway defined in this configuration */ default QueryGateway queryGateway() { return getComponent(QueryGateway.class); }
/** * Returns the Component declared under the given {@code componentType}, typically the interface the component * implements. * * @param componentType The type of component * @param <T> The type of component * @return the component registered for the given type, or {@code null} if no such component exists */ default <T> T getComponent(Class<T> componentType) { return getComponent(componentType, () -> null); }
/** * Returns the Command Gateway defined in this Configuration. Note that this Configuration should be started (see * {@link #start()}) before sending Commands using this Command Gateway. * * @return the CommandGateway defined in this configuration */ default CommandGateway commandGateway() { return getComponent(CommandGateway.class); }
/** * Returns the serializer defined in this Configuration * * @return the serializer defined in this Configuration */ default Serializer serializer() { return getComponent(Serializer.class); }
/** * Returns the Deadline Manager defined in this Configuration. * * @return the Deadline Manager defined in this Configuration */ default DeadlineManager deadlineManager() { return getComponent(DeadlineManager.class); }
public EventProcessorInfoConfiguration() { this(Configuration::eventProcessingConfiguration, c -> c.getComponent(AxonServerConnectionManager.class), c -> c.getComponent(AxonServerConfiguration.class)); }
/** * Returns the Command Bus defined in this Configuration. Note that this Configuration should be started (see * {@link #start()}) before sending Commands over the Command Bus. * * @return the CommandBus defined in this configuration */ default CommandBus commandBus() { return getComponent(CommandBus.class); }
/** * Returns the ResourceInjector used to provide resources to Saga instances. * * @return the ResourceInjector used to provide resources to Saga instances */ default ResourceInjector resourceInjector() { return getComponent(ResourceInjector.class, () -> NoResourceInjector.INSTANCE); }
/** * Returns the Parameter Resolver Factory defined in this Configuration * * @return the Parameter Resolver Factory defined in this Configuration */ default ParameterResolverFactory parameterResolverFactory() { return getComponent(ParameterResolverFactory.class); }
@Override protected <R> Optional<R> findResource(Class<R> requiredType) { return Optional.ofNullable(configuration.getComponent(requiredType)); } }
@SuppressWarnings("unchecked") private <T> T getBean(String beanName, Configuration configuration) { return (T) configuration.getComponent(ApplicationContext.class).getBean(beanName); }
@Override public ParameterResolver<?> createInstance(Executable executable, Parameter[] parameters, int parameterIndex) { Object component = configuration.getComponent(parameters[parameterIndex].getType()); return component == null ? null : new FixedValueParameterResolver<>(component); } }
private AxonServerCommandBus buildCommandBus(Configuration c) { AxonServerCommandBus commandBus = new AxonServerCommandBus(c.getComponent(AxonServerConnectionManager.class), c.getComponent(AxonServerConfiguration.class), SimpleCommandBus.builder().build(), c.messageSerializer(), c.getComponent(RoutingStrategy.class, AnnotationRoutingStrategy::new), c.getComponent(CommandPriorityCalculator.class, () -> new CommandPriorityCalculator() {})); c.onShutdown(commandBus::disconnect); return commandBus; }
private AxonServerConnectionManager buildAxonServerConnectionManager(Configuration c) { AxonServerConnectionManager axonServerConnectionManager = new AxonServerConnectionManager(c.getComponent( AxonServerConfiguration.class)); c.onShutdown(axonServerConnectionManager::shutdown); return axonServerConnectionManager; }
/** * Provides the default Serializer implementation. Subclasses may override this method to provide their own default. * * @param config The configuration based on which the component is initialized. * @return The default Serializer to use. */ protected Serializer defaultSerializer(Configuration config) { return XStreamSerializer.builder() .revisionResolver(config.getComponent(RevisionResolver.class, AnnotationRevisionResolver::new)) .build(); }
private QueryBus buildQueryBus(Configuration c) { SimpleQueryBus localSegment = SimpleQueryBus.builder() .transactionManager(c.getComponent(TransactionManager.class, NoTransactionManager::instance)) .errorHandler(c.getComponent(QueryInvocationErrorHandler.class, () -> LoggingQueryInvocationErrorHandler.builder().build())) .queryUpdateEmitter(c.queryUpdateEmitter()) .messageMonitor(c.messageMonitor(QueryBus.class, "localQueryBus")) .build(); AxonServerQueryBus queryBus = new AxonServerQueryBus(c.getComponent(AxonServerConnectionManager.class), c.getComponent(AxonServerConfiguration.class), c.queryUpdateEmitter(), localSegment, c.messageSerializer(), c.serializer(), c.getComponent(QueryPriorityCalculator.class, () -> new QueryPriorityCalculator() {})); c.onShutdown(queryBus::disconnect); return queryBus; }
private AxonServerEventStore buildEventStore(Configuration c) { return AxonServerEventStore.builder() .configuration(c.getComponent(AxonServerConfiguration.class)) .platformConnectionManager(c.getComponent(AxonServerConnectionManager.class)) .snapshotSerializer(c.serializer()) .eventSerializer(c.eventSerializer()) .upcasterChain(c.upcasterChain()) .build(); }