Class CheckoutService

java.lang.Object
com.homannsoftware.transactions.CheckoutService

@Service public class CheckoutService extends Object
Defines the transaction boundary for one local checkout use case.
  • Constructor Details

    • CheckoutService

      public CheckoutService(CheckoutRepository repository)
      Creates the service through constructor injection.
      Parameters:
      repository - SQL adapter using the same DataSource
  • Method Details

    • checkout

      @Transactional public void checkout(String orderRef, String sku, int quantity)
      Reserves inventory and records an order as one atomic database change.
      Parameters:
      orderRef - nonblank reference of at most 80 characters
      sku - nonblank product identifier of at most 40 characters
      quantity - positive number of units
      Throws:
      IllegalArgumentException - if an argument is invalid
      OutOfStockException - if the product is missing or insufficient