We have four modules in this recipe:
- book.service: This is the module which contains our service provider interface that is, the service
- mongodb.book.service: This is one of the service provider module
- sqldb.book.service: This is the other service provider module
- book.manage: This is the service consumer module
The following steps demonstrate how to make use of ServiceLoader to achieve loose coupling:
- Create a folder book.service under the directory chp3/8_services/src. All our code for book.service module will be under this folder.
- Create a new package com.packt.model and a new class Book under the new package. This is our model class which contains the following properties:
public String id; public String ...