![Page 1: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/1.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Modules and Services
Alex Buckley Java Platform Group, Oracle September 2016
![Page 2: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/2.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
I. Introduction to Services
II. Services for Optional Dependencies
III. Service Binding
2
![Page 3: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/3.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Part I. Introduction to Services
3
![Page 4: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/4.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Module Dependencies
4
module java.desktop {
requires java.xml;
exports java.awt;
}
myapp java.desktop
class java.awt.Button accesses
class Main
requires java.xml
class javax.xml.parsers.DocumentBuilder
accesses
requires
exports exports
![Page 5: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/5.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Service Relationships
5
java.desktop
interface javax.print.PrintServiceLookup
printlib
class FastPrint implements PrintServiceLookup
class Printers
![Page 6: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/6.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Expressing Service Relationships
6
// Consumer module
module java.desktop {
requires java.xml;
exports java.awt;
uses javax.print.PrintServiceLookup;
}
// Provider module
module printlib {
provides javax.print.PrintServiceLookup
with com.printlib.FastPrint;
}
![Page 7: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/7.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 7
ServiceLoader<PrintServiceLookup> psls =
ServiceLoader.load(PrintServiceLookup.class);
for (PrintServiceLookup psl : psls) {
PrintService ps = psl.getDefaultPrintService();
if (ps.isDocFlavorSupported(…)) return ps;
}
return DEFAULT_PRINT_SERVICE;
Using The Service Type in java.desktop
![Page 8: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/8.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 8
Choosing a Provider Class
java.desktop
interface javax.print.PrintServiceLookup
printlib
class FastPrint implements PrintServiceLookup
class Printers netprint
class NetPrint implements PrintServiceLookup
uses
provides
provides
![Page 9: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/9.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 9
Choosing a Provider Class
java.desktop
interface javax.print.PrintServiceLookup
class Printers
ServiceLoader<PrintServiceLookup> psls = ServiceLoader.load(PrintServiceLookup.class);
for (PrintServiceLookup psl : psls) {
PrintService ps = psl.getDefaultPrintService();
if (ps.isDocFlavorSupported(…)) return ps;
}
return DEFAULT_PRINT_SERVICE;
uses
![Page 10: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/10.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 10
Designing a Service Type interface PrintServiceLookup {
PrintService getDefaultPrintService();
PrintService[] getPrintServices();
PrintService[] getPrintServices(DocFlavor);
}
interface PrintService {
DocFlavor[] getSupportedDocFlavors();
boolean isDocFlavorSupported();
void createPrintJob();
}
![Page 11: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/11.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 11
uses java.awt.im.spi.InputMethodDescriptor; uses javax.accessibility.AccessibilityProvider; uses javax.imageio.spi.ImageInputStreamSpi; uses javax.imageio.spi.ImageOutputStreamSpi; uses javax.imageio.spi.ImageReaderSpi; uses javax.imageio.spi.ImageTranscoderSpi; uses javax.imageio.spi.ImageWriterSpi; uses javax.print.PrintServiceLookup; uses javax.print.StreamPrintServiceFactory; uses javax.sound.midi.spi.MidiDeviceProvider; uses javax.sound.midi.spi.MidiFileReader; uses javax.sound.midi.spi.MidiFileWriter; uses javax.sound.midi.spi.SoundbankReader; uses javax.sound.sampled.spi.AudioFileReader; uses javax.sound.sampled.spi.AudioFileWriter; uses javax.sound.sampled.spi.FormatConversionProvider; uses javax.sound.sampled.spi.MixerProvider;
java.desktop as a Consumer Module
![Page 12: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/12.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Foo
12
Service Types in Modules
javafx.graphics
class FXPrinters
java.desktop
interface javax.print.PrintServiceLookup
printlib
class FastPrint
class Printers
netprint
class NetPrint
requires exports
![Page 13: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/13.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Foo
13
Service Types in Modules
javafx.graphics
class FXPrinters
java.desktop
interface javax.print.PrintServiceLookup
printlib
class FastPrint
class Printers
netprint
class NetPrint
uses accesses
![Page 14: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/14.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Foo
14
Service Types in Modules
javafx.graphics
class FXPrinters
java.desktop
interface javax.print.PrintServiceLookup
printlib
class FastPrint
class Printers
netprint
class NetPrint
provides accesses
![Page 15: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/15.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Foo
15
Service Types in Modules
javafx.graphics
class FXPrinters
java.desktop
interface javax.print.PrintServiceLookup
printlib
class FastPrint
class Printers
netprint
class NetPrint
![Page 16: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/16.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16
uses java.awt.im.spi.InputMethodDescriptor; uses javax.accessibility.AccessibilityProvider; uses javax.imageio.spi.ImageInputStreamSpi; uses javax.imageio.spi.ImageOutputStreamSpi; uses javax.imageio.spi.ImageReaderSpi; uses javax.imageio.spi.ImageTranscoderSpi; uses javax.imageio.spi.ImageWriterSpi; uses javax.print.PrintServiceLookup; uses javax.print.StreamPrintServiceFactory; uses javax.sound.midi.spi.MidiDeviceProvider; uses javax.sound.midi.spi.MidiFileReader; uses javax.sound.midi.spi.MidiFileWriter; uses javax.sound.midi.spi.SoundbankReader; uses javax.sound.sampled.spi.AudioFileReader; uses javax.sound.sampled.spi.AudioFileWriter; uses javax.sound.sampled.spi.FormatConversionProvider; uses javax.sound.sampled.spi.MixerProvider;
Service Types in java.desktop exports java.awt.im.spi; exports javax.accessibility; exports javax.imageio.spi; exports javax.print; exports javax.sound.midi.spi; exports javax.sound.sampled.spi;
![Page 17: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/17.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 17
uses javax.print.PrintServiceLookup; uses javax.print.StreamPrintServiceFactory; uses javax.sound.sampled.spi.AudioFileReader;
java.desktop as a Provider Module
provides javax.print.PrintServiceLookup with sun.print.PrintServiceLookupProvider; provides javax.print.StreamPrintServiceFactory with sun.print.PSStreamPrinterFactory; provides javax.sound.sampled.spi.AudioFileReader with com.sun.media.sound.AiffFileReader; provides javax.sound.sampled.spi.AudioFileReader with com.sun.media.sound.AuFileReader; provides javax.sound.sampled.spi.AudioFileReader with com.sun.media.sound.WaveFileReader;
![Page 18: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/18.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 18
Stream<Provider<PrintServiceLookup>> providers =
ServiceLoader.load(PrintServiceLookup.class)
.stream()
.filter(p -> p.type().isAnnotationPresent(…));
PrintServiceLookup psl =
providers.map(Provider::get)
.findAny()
.orElse(DEFAULT_PRINT_SERVICE);
Using The Service Type (Advanced)
![Page 19: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/19.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Documenting Services
19
module java.desktop {
/**
* @uses javax.print.PrintServiceLookup Supports providers that … */ uses javax.print.PrintServiceLookup;
}
module printlib {
/**
* @provides javax.print.PrintServiceLookup The FastPrint class can … */ provides javax.print.PrintServiceLookup with com.printlib.FastPrint;
}
![Page 20: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/20.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Summary of Part I. Introduction to Services
• Service relationships are first class in the module system
• Programming against service types means providers can be encapsulated
• Many JDK frameworks build on services, and are customized with them
20
![Page 21: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/21.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Part II. Services for Optional Dependencies
21
![Page 22: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/22.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
22
![Page 23: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/23.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 23
Optional Module Dependencies
module java.scripting {
requires optional jdk.scripting.nashorn;
requires optional groovy.scriptengine;
}
java.scripting
jdk.scripting.nashorn
class Nashorn …
class Eval … groovy.scriptengine
class Groovy…
requires optional
requires optional
?
![Page 24: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/24.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 24
Encoding Optionality with Service Relationships
java.scripting jdk.scripting.nashorn
class Nashorn … class Eval …
requires optional
java.scripting
class Eval …
Service Type Module
interface ScriptEngineFactory
jdk.scripting.nashorn
class Nashorn … uses provides
requires requires
?
![Page 25: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/25.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 25
Encoding Optionality module java.scripting {
uses javax.script.ScriptEngineFactory;
exports javax.script;
}
module jdk.scripting.nashorn {
provides javax.script.ScriptEngineFactory
with jdk.nashorn.api.scripting.NashornScriptEngineFactory;
requires java.scripting;
}
module groovy.scriptengine {
provides javax.script.ScriptEngineFactory
with groovy.backend.CodeEvaluationEngineFactory;
requires java.scripting;
}
![Page 26: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/26.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Summary of Part II. Optional Dependencies
• Service relationships encode optional module dependencies
• Services give not just loose coupling, but better separation of concerns
• Services are almost always a better choice than messing with reflection
26
![Page 27: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/27.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Part III: Service Binding
27
![Page 28: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/28.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Why Declare Services In The Module System?
• Strong encapsulation
•Reliable configuration
28
![Page 29: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/29.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 29
Service Binding
Module A
interface I
Module B uses provides
![Page 30: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/30.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 30
Service Binding
Module A uses
interface I
Module B provides
requires
Module C
interface J
Module D uses provides
![Page 31: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/31.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 31
Module Resolution with Service Binding
Module A
Module M
requires
![Page 32: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/32.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 32
Module Resolution with Service Binding
Module A
interface I
Module M
Module B
Module N
interface J
requires
uses provides
uses provides
![Page 33: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/33.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 33
Module Resolution with Service Binding
Module C requires
Module O requires
Module A
interface I
Module M
Module B
Module N
interface J
requires
uses provides
uses provides
![Page 34: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/34.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 34
Module Resolution with Service Binding
Module D
Module P
Module C
Module O
Module A
interface I
Module M
Module B
Module N
interface J
requires
uses provides
uses provides
requires
requires
interface K
interface L
uses provides
uses provides
![Page 35: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/35.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 35
Module Resolution with Service Binding
Module A
interface I
Module M
Module B
Module N
interface J
requires
uses provides
uses provides
![Page 36: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/36.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 36
Module Resolution with Service Binding
Module A
interface I
Module M
Module B
Module N
interface J
requires
uses provides
uses provides
interface K
Module E
Module Q
interface L
uses provides
uses provides
![Page 37: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/37.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
jlink and Service Relationships
37
Module A
interface I
Module M
Module B
Module N
interface J
requires
uses provides
uses provides
interface K
Module E
Module Q
interface L
uses provides
uses provides
![Page 38: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/38.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Services and the Unnamed Module
38
Unnamed module
java.base java.sql
jdk.compiler jdk.javadoc
Named modules
guava.jar junit.jar
glassfish.jar hibernate.jar
requires
requires
requires
requires
provides
![Page 39: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/39.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Services and the Unnamed Module
39
Unnamed module
java.base java.sql
jdk.compiler jdk.javadoc
Named modules
guava.jar junit.jar
glassfish.jar hibernate.jar
uses
uses
uses
uses
provides
![Page 40: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/40.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Services and Automatic Modules
40
Unnamed module
java.base java.sql
jdk.compiler jdk.javadoc
Named modules
guava junit.jar
glassfish.jar hibernate.jar
![Page 41: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/41.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Summary of Part III. Service Binding
• Service binding is an iterative process that augments the module graph
• Service binding is agnostic to explicit, automatic, and unnamed modules
• Service binding is orthogonal to linking a Java runtime image
41
![Page 42: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/42.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Summary of Summaries
• Service relationships are first class in the module system
• Services give not just loose coupling, but better separation of concerns
• Service binding is agnostic to explicit, automatic, and unnamed modules
42
![Page 43: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/43.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Preparing for JDK 9
• JDK 8: Run jdeps –jdkinternals MyApp.jar
• JDK 9: Early Access binaries at http://jdk9.java.net/
• JEP 261: Module System
• JEP 260: Encapsulate Most Internal APIs
• JEP 223: New Version String Scheme
• JEP 220: Modular Run-Time Images
• JEP 200: The Modular JDK
43
![Page 44: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/44.jpg)
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.
Safe Harbor Statement
The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
44
![Page 45: Modules and Services - OpenJDKopenjdk.java.net/projects/jigsaw/talks/modules-and-services-j1... · Copyright © 2016, Oracle and/or its affiliates. All rights reserved. 16 uses java.awt.im.spi.InputMethodDescriptor;](https://reader031.vdocuments.net/reader031/viewer/2022022104/5bcdf40209d3f2f55e8b5fff/html5/thumbnails/45.jpg)