Skip to content

Commit

Permalink
Changed factories to call initialize(), Removed unneeded uses of init…
Browse files Browse the repository at this point in the history
  • Loading branch information
cer committed May 20, 2023
1 parent 2e8071d commit 2d6c633
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public SagaCommandDispatcherFactory(MessageConsumer messageConsumer,
}

public SagaCommandDispatcher make(String commandDispatcherId, CommandHandlers target) {
return new SagaCommandDispatcher(commandDispatcherId, target, messageConsumer, sagaLockManager, commandNameMapping, commandReplyProducer);
SagaCommandDispatcher sagaCommandDispatcher = new SagaCommandDispatcher(commandDispatcherId, target, messageConsumer, sagaLockManager, commandNameMapping, commandReplyProducer);
sagaCommandDispatcher.initialize();
return sagaCommandDispatcher;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public ReactiveSagaCommandDispatcherFactory(ReactiveMessageConsumer messageConsu
}

public ReactiveSagaCommandDispatcher make(String commandDispatcherId, ReactiveCommandHandlers target) {
return new ReactiveSagaCommandDispatcher(commandDispatcherId, target, messageConsumer, sagaLockManager, commandReplyProducer);
ReactiveSagaCommandDispatcher reactiveSagaCommandDispatcher = new ReactiveSagaCommandDispatcher(commandDispatcherId, target, messageConsumer, sagaLockManager, commandReplyProducer);
reactiveSagaCommandDispatcher.initialize();
return reactiveSagaCommandDispatcher;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
import io.eventuate.tram.reactive.commands.consumer.ReactiveCommandDispatcher;
import io.eventuate.tram.sagas.reactive.participant.ReactiveSagaCommandDispatcherFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
import org.springframework.transaction.reactive.TransactionalOperator;

@Configuration
Expand All @@ -30,7 +27,7 @@ public CustomerCommandHandler customerCommandHandler(CustomerService customerSer
return new CustomerCommandHandler(customerService);
}

@Bean(initMethod = "initialize")
@Bean
public ReactiveCommandDispatcher consumerCommandDispatcher(CustomerCommandHandler target,
ReactiveSagaCommandDispatcherFactory sagaCommandDispatcherFactory) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import io.eventuate.examples.tram.sagas.ordersandcustomers.customers.service.CustomerCommandHandler;
import io.eventuate.examples.tram.sagas.ordersandcustomers.customers.service.CustomerService;
import io.eventuate.tram.commands.consumer.CommandDispatcher;
import io.eventuate.tram.sagas.common.SagaLockManager;
import io.eventuate.tram.sagas.participant.SagaCommandDispatcherFactory;
import io.eventuate.tram.sagas.spring.participant.SagaParticipantConfiguration;
import io.eventuate.tram.spring.optimisticlocking.OptimisticLockingDecoratorConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
Expand Down Expand Up @@ -36,9 +34,9 @@ public CustomerCommandHandler customerCommandHandler(CustomerDao customerDao) {

// TODO Exception handler for CustomerCreditLimitExceededException

@Bean(initMethod = "initialize")
@Bean
public CommandDispatcher consumerCommandDispatcher(CustomerCommandHandler target,
SagaLockManager sagaLockManager, SagaCommandDispatcherFactory sagaCommandDispatcherFactory) {
SagaCommandDispatcherFactory sagaCommandDispatcherFactory) {

return sagaCommandDispatcherFactory.make("customerCommandDispatcher", target.commandHandlerDefinitions());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public OrderCommandHandler orderCommandHandler(OrderDao orderDao) {
return new OrderCommandHandler(orderDao);
}

@Bean(initMethod = "initialize")
@Bean
public CommandDispatcher orderCommandDispatcher(OrderCommandHandler target, SagaCommandDispatcherFactory sagaCommandDispatcherFactory) {
return sagaCommandDispatcherFactory.make("orderCommandDispatcher", target.commandHandlerDefinitions());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import io.eventuate.examples.tram.sagas.ordersandcustomers.orders.sagas.createorder.CreateOrderSaga;
import io.eventuate.examples.tram.sagas.ordersandcustomers.spring.customers.CustomerConfiguration;
import io.eventuate.examples.tram.sagas.ordersandcustomers.spring.orders.OrderConfiguration;
import io.eventuate.tram.spring.commands.producer.TramCommandProducerConfiguration;
import io.eventuate.tram.spring.events.publisher.TramEventsPublisherConfiguration;
import io.eventuate.tram.spring.events.subscriber.TramEventSubscriberConfiguration;
import io.eventuate.tram.events.subscriber.DomainEventDispatcher;
import io.eventuate.tram.events.subscriber.DomainEventDispatcherFactory;
import io.eventuate.tram.messaging.common.ChannelMapping;
import io.eventuate.tram.messaging.common.DefaultChannelMapping;
import io.eventuate.tram.sagas.spring.orchestration.SagaOrchestratorConfiguration;
import io.eventuate.tram.spring.commands.producer.TramCommandProducerConfiguration;
import io.eventuate.tram.spring.events.publisher.TramEventsPublisherConfiguration;
import io.eventuate.tram.spring.events.subscriber.TramEventSubscriberConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -51,7 +51,7 @@ public SagaEventsConsumer sagaEventsConsumer() {
return new SagaEventsConsumer();
}

@Bean(initMethod = "initialize")
@Bean
public DomainEventDispatcher domainEventDispatcher(TramCommandsAndEventsIntegrationData tramCommandsAndEventsIntegrationData, SagaEventsConsumer sagaEventsConsumer, DomainEventDispatcherFactory domainEventDispatcherFactory) {
return domainEventDispatcherFactory.make(tramCommandsAndEventsIntegrationData.getEventDispatcherId(), sagaEventsConsumer.domainEventHandlers());
}
Expand Down

0 comments on commit 2d6c633

Please sign in to comment.