O'Reilly logo

Spring MVC Beginner’s Guide by Amuthan G

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. Open the interface ProductRepository from the package com.packt.webstore.domain.repository in the source folder src/main/java, and add one more method declaration on it, as follows:
    Product getProductById(String productID);
  2. 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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required