Now that we have an understanding of how to create and consume services, let's put this to practice in the address book viewer application. We'll create multiple sorting implementation modules and register these implementations as services. We'll then update the packt.addressbook module to use the ServiceLoader API to get the sorting instances, and then use one of these instances to sort the contacts list. Let's run through the five steps we've just learned in order to achieve this:
- Create the Java type that defines the service: We'll retain the interface SortUtil to be the common interface that various implementation types will use. The packt.sortutil module contains both the interface and implementation types ...