Class CustomerApplicationService

java.lang.Object
com.example.orderplatform.customers.application.CustomerApplicationService
All Implemented Interfaces:
CustomerDirectory

@Service @Transactional public class CustomerApplicationService extends Object implements CustomerDirectory
Application service that registers customers and backs the customer lookup module API.
  • Constructor Details

    • CustomerApplicationService

      public CustomerApplicationService(CustomerStore customers)
  • Method Details

    • createCustomer

      public CustomerSnapshot createCustomer(String fullName, String email)
      Registers a new active customer after normalizing and validating the submitted identity fields.
      Parameters:
      fullName - customer display name
      email - customer email address
      Returns:
      created customer snapshot
      Throws:
      ResourceConflictException - when another customer already uses the email address
    • getRequiredCustomer

      @Transactional(readOnly=true) public CustomerSnapshot getRequiredCustomer(UUID customerId)
      Retrieves the customer snapshot required by order placement.
      Specified by:
      getRequiredCustomer in interface CustomerDirectory
      Parameters:
      customerId - customer identifier
      Returns:
      immutable customer snapshot
      Throws:
      ResourceNotFoundException - when the customer does not exist