4.4.4 OrderServiceConfiguration 클래스
주문 서비스는 스프링 프레임워크를 사용합니다. 예제 4-7은 OrderServiceConfiguration 클래스 코드의 일부입니다. 클래스 선언부에 @Configuration을 붙인 스프링 빈 구성 클래스입니다.
예제 4-7 OrderserviceConfiguration은 Orderservice의 스프링 빈이 정의된 구성 클래스다
@Configuration
public class OrderServiceConfiguration {
@Bean
public OrderService orderService(RestaurantRepository restaurantRepository,
...
SagaManager<CreateOrderSagaState> createOrderSagaManager,
...) {
return new OrderService(restaurantRepository,
...
CreateOrderSagaManager
...);
}
@Bean
public SagaManager<CreateOrderSagaState> createOrderSagaManager(
CreateOrderSaga saga) {
return new SagaManagerImpl<>(saga);
}
@Bean
public CreateOrderSaga createOrderSaga(OrderServiceProxy orderService,
ConsumerServiceProxy consumerService, ...) {
return new CreateOrderSaga(orderService, consumerService, ...);
}
@Bean
public OrderCommandHandlers orderCommandHandlers() {
return new OrderCommandHandlers();
}
@Bean
public SagaCommandDispatcher orderCommandHandlersDispatcher(
OrderCommandHandlers orderCommandHandlers) {
return new SagaCommandDispatcher("orderService",
orderCommandHandlers.commandHandlers());
}
@Bean
public KitchenServiceProxy kitchenServiceProxy() {
return new KitchenServiceProxy();
}
@Bean
public OrderServiceProxy orderServiceProxy() {
return new OrderServiceProxy();
}
...
}