What the pattern is trying to achieve
Expose a clear use-case boundary that orchestrates domain and infrastructure collaborators.
Application Service is a modern, widely used way to express the enterprise use-case boundary that older catalogs often described through Session Facade-like ideas.
In order systems, place order, cancel shipment, and refund payment are use cases, not entity methods. Application services coordinate those use cases without collapsing domain modeling into controllers.
Expose a clear use-case boundary that orchestrates domain and infrastructure collaborators.
Controllers, message handlers, or scheduled jobs start coordinating business workflows directly and blur the application boundary.
Introduce an application service that owns the use-case level orchestration and transaction boundary.
This is one of the most common and practical pattern shapes in Spring and modern enterprise Java.
package org.javaomnibus.ecommerce.application;
public final class CancelOrderApplicationService {
private final OrderRepository orderRepository;
private final RefundGateway refundGateway;
private final NotificationService notificationService;
public CancelOrderApplicationService(
OrderRepository orderRepository,
RefundGateway refundGateway,
NotificationService notificationService
) {
this.orderRepository = orderRepository;
this.refundGateway = refundGateway;
this.notificationService = notificationService;
}
public void cancel(String orderId) {
Order order = orderRepository.requireById(orderId);
order.cancel();
refundGateway.refund(order.paymentReference());
notificationService.sendCancellation(order);
orderRepository.save(order);
}
}
Application Service is the modern everyday form of many Session Facade responsibilities. Session Facade emphasizes coarse-grained enterprise interaction, while Application Service is the cleaner contemporary term in many DI-based systems.