Skip to Content
Java 9 Dependency Injection
book

Java 9 Dependency Injection

by Nilang Patel, Krunal Patel
April 2018
Intermediate to advanced content levelIntermediate to advanced
246 pages
6h 11m
English
Packt Publishing
Content preview from Java 9 Dependency Injection

Service provider (Implementation) module

Now, create a service provider module com.packt.service.impl to implement NotificationService service API, and for that we should define a "provides ... with" clause in the module-info.java file. The provides keyword is used to mention the service interface name and the with keyword is used to mention which implementation we want to load. In the event that the module doesn’t have the provides statement in the module descriptor file, the service loader will not load that module. The syntax of the 'provides...with' statement is as follows:

provides <service-interface> with <service-implementation>

To send an SMS message to a recipient we are creating two implementation classes, SMSServiceImpl.java 

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro CDI 2 in Java EE 8: An In-Depth Guide to Context and Dependency Injection

Pro CDI 2 in Java EE 8: An In-Depth Guide to Context and Dependency Injection

Jan Beernink, Arjan Tijms
Dependency Injection

Dependency Injection

Dhananjay Prasanna

Publisher Resources

ISBN: 9781788296250Supplemental Content