Time for action – creating a service object
Perform the following steps to create a service object that will perform the simple business operation of order processing:
- Open the interface
ProductRepository
from the packagecom.packt.webstore.domain.repository
in the source foldersrc/main/java
, and add one more method declaration on it, as follows:Product getProductById(String productID);
- Open the implementation class
InMemoryProductRepository
and add an implantation for the previously declared method, as follows:public Product getProductById(String productId) { Product productById = null; for(Product product : listOfProducts) { if(product!=null && product.getProductId()!=null && product.getProductId().equals(productId)){ productById = product; break; ...
Get Spring MVC Beginner’s Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.