@Override public void onStart(int phase, Runnable startHandler) { startHandlers.add(new RunnableHandler(phase, startHandler)); }
@Override public void onShutdown(int phase, Runnable shutdownHandler) { shutdownHandlers.add(new RunnableHandler(phase, shutdownHandler)); }
@Override public <A> Configurer configureAggregate(AggregateConfiguration<A> aggregateConfiguration) { this.modules.add(aggregateConfiguration); this.aggregateConfigurations.put(aggregateConfiguration.aggregateType(), aggregateConfiguration); this.initHandlers.add(new ConsumerHandler(aggregateConfiguration.phase(), aggregateConfiguration::initialize)); this.startHandlers.add(new RunnableHandler(aggregateConfiguration.phase(), aggregateConfiguration::start)); this.shutdownHandlers.add( new RunnableHandler(aggregateConfiguration.phase(), aggregateConfiguration::shutdown) ); return this; }
@Override @SuppressWarnings("unchecked") public Configurer registerQueryHandler(int phase, Function<Configuration, Object> annotatedQueryHandlerBuilder) { startHandlers.add(new RunnableHandler(phase, () -> { Object annotatedHandler = annotatedQueryHandlerBuilder.apply(config); Assert.notNull(annotatedHandler, () -> "annotatedQueryHandler may not be null"); Registration registration = new AnnotationQueryHandlerAdapter(annotatedHandler, config.parameterResolverFactory(), config.handlerDefinition(annotatedHandler .getClass())) .subscribe(config.queryBus()); shutdownHandlers.add(new RunnableHandler(phase, registration::cancel)); })); return this; }
@Override @SuppressWarnings("unchecked") public Configurer registerQueryHandler(int phase, Function<Configuration, Object> annotatedQueryHandlerBuilder) { startHandlers.add(new RunnableHandler(phase, () -> { Object annotatedHandler = annotatedQueryHandlerBuilder.apply(config); Assert.notNull(annotatedHandler, () -> "annotatedQueryHandler may not be null"); Registration registration = new AnnotationQueryHandlerAdapter(annotatedHandler, config.parameterResolverFactory(), config.handlerDefinition(annotatedHandler .getClass())) .subscribe(config.queryBus()); shutdownHandlers.add(new RunnableHandler(phase, registration::cancel)); })); return this; }
@Override public Configurer registerCommandHandler(int phase, Function<Configuration, Object> annotatedCommandHandlerBuilder) { startHandlers.add(new RunnableHandler(phase, () -> { Object handler = annotatedCommandHandlerBuilder.apply(config); Assert.notNull(handler, () -> "annotatedCommandHandler may not be null"); Registration registration = new AnnotationCommandHandlerAdapter(handler, config.parameterResolverFactory(), config.handlerDefinition(handler.getClass())) .subscribe(config.commandBus()); shutdownHandlers.add(new RunnableHandler(phase, registration::cancel)); })); return this; }
@Override public void onShutdown(int phase, Runnable shutdownHandler) { shutdownHandlers.add(new RunnableHandler(phase, shutdownHandler)); }
@Override public void onStart(int phase, Runnable startHandler) { startHandlers.add(new RunnableHandler(phase, startHandler)); }
@Override public void onStart(int phase, Runnable startHandler) { startHandlers.add(new RunnableHandler(phase, startHandler)); }
/** * Prepare the registered modules for initialization. This ensures all lifecycle handlers are registered. */ protected void prepareModules() { modules.forEach(module -> { initHandlers.add(new ConsumerHandler(module.phase(), module::initialize)); startHandlers.add(new RunnableHandler(module.phase(), module::start)); shutdownHandlers.add(new RunnableHandler(module.phase(), module::shutdown)); }); }
@Override public <A> Configurer configureAggregate(AggregateConfiguration<A> aggregateConfiguration) { this.modules.add(aggregateConfiguration); this.aggregateConfigurations.put(aggregateConfiguration.aggregateType(), aggregateConfiguration); this.initHandlers.add(new ConsumerHandler(aggregateConfiguration.phase(), aggregateConfiguration::initialize)); this.startHandlers.add(new RunnableHandler(aggregateConfiguration.phase(), aggregateConfiguration::start)); this.shutdownHandlers.add( new RunnableHandler(aggregateConfiguration.phase(), aggregateConfiguration::shutdown) ); return this; }
/** * Prepare the registered modules for initialization. This ensures all lifecycle handlers are registered. */ protected void prepareModules() { modules.forEach(module -> { initHandlers.add(new ConsumerHandler(module.phase(), module::initialize)); startHandlers.add(new RunnableHandler(module.phase(), module::start)); shutdownHandlers.add(new RunnableHandler(module.phase(), module::shutdown)); }); }
@Override public Configurer registerModule(ModuleConfiguration module) { if (initialized) { module.initialize(config); startHandlers.add(new RunnableHandler(module.phase(), module::start)); shutdownHandlers.add(new RunnableHandler(module.phase(), module::shutdown)); } this.modules.add(module); return this; }
@Override public Configurer registerModule(ModuleConfiguration module) { if (initialized) { module.initialize(config); startHandlers.add(new RunnableHandler(module.phase(), module::start)); shutdownHandlers.add(new RunnableHandler(module.phase(), module::shutdown)); } this.modules.add(module); return this; }
@Override public void onShutdown(int phase, Runnable shutdownHandler) { shutdownHandlers.add(new RunnableHandler(phase, shutdownHandler)); }
@Override public <A> Configurer configureAggregate(AggregateConfiguration<A> aggregateConfiguration) { this.modules.add(aggregateConfiguration); this.aggregateConfigurations.put(aggregateConfiguration.aggregateType(), aggregateConfiguration); this.initHandlers.add(new ConsumerHandler(aggregateConfiguration.phase(), aggregateConfiguration::initialize)); this.startHandlers.add(new RunnableHandler(aggregateConfiguration.phase(), aggregateConfiguration::start)); this.shutdownHandlers.add( new RunnableHandler(aggregateConfiguration.phase(), aggregateConfiguration::shutdown) ); return this; }
@Override @SuppressWarnings("unchecked") public Configurer registerQueryHandler(int phase, Function<Configuration, Object> annotatedQueryHandlerBuilder) { startHandlers.add(new RunnableHandler(phase, () -> { Object annotatedHandler = annotatedQueryHandlerBuilder.apply(config); Assert.notNull(annotatedHandler, () -> "annotatedQueryHandler may not be null"); Registration registration = new AnnotationQueryHandlerAdapter(annotatedHandler, config.parameterResolverFactory(), config.handlerDefinition(annotatedHandler .getClass())) .subscribe(config.queryBus()); shutdownHandlers.add(new RunnableHandler(phase, registration::cancel)); })); return this; }
@Override public Configurer registerCommandHandler(int phase, Function<Configuration, Object> annotatedCommandHandlerBuilder) { startHandlers.add(new RunnableHandler(phase, () -> { Object handler = annotatedCommandHandlerBuilder.apply(config); Assert.notNull(handler, () -> "annotatedCommandHandler may not be null"); Registration registration = new AnnotationCommandHandlerAdapter(handler, config.parameterResolverFactory(), config.handlerDefinition(handler.getClass())) .subscribe(config.commandBus()); shutdownHandlers.add(new RunnableHandler(phase, registration::cancel)); })); return this; }
@Override public Configurer registerModule(ModuleConfiguration module) { if (initialized) { module.initialize(config); startHandlers.add(new RunnableHandler(module.phase(), module::start)); shutdownHandlers.add(new RunnableHandler(module.phase(), module::shutdown)); } this.modules.add(module); return this; }
/** * Prepare the registered modules for initialization. This ensures all lifecycle handlers are registered. */ protected void prepareModules() { modules.forEach(module -> { initHandlers.add(new ConsumerHandler(module.phase(), module::initialize)); startHandlers.add(new RunnableHandler(module.phase(), module::start)); shutdownHandlers.add(new RunnableHandler(module.phase(), module::shutdown)); }); }