@Before("audited(product, quantity)") public void audit(JoinPoint jp, Product product, int quantity) { System.out.println( "Audit: operation = " + jp.getSignature().getName() + " product = " + product.getName() + " quantity = " + quantity); }
public void removeProduct(Product product, int quantity) { if (isProductAvailable(product, quantity)) { InventoryItem inventoryItem = inventoryRepository.findByProduct(product); inventoryItem.deplete(quantity); } else { throw new InventoryException( "Insufficient inventory to fulfil" + " request for " + product.getName() + " quantity " + quantity); } }