We have four modules in this recipe:
- book.service: This is the module that contains our service provider interface, that is, the service
- mongodb.book.service: This is one of the service provider modules
- 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 book.service folder under the Chapter03/8_services/src directory. All our code for the 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; ...