Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications
298Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications
298Paperback
-
PICK UP IN STORECheck Availability at Nearby Stores
Available within 2 business hours
Related collections and offers
Overview
- Understand the Java Platform Module System concepts
- Master the patterns and practices for building truly modular applications
- Migrate existing applications and libraries to Java modules
- Use JDK tools for modular development and migration
Product Details
ISBN-13: | 9781491954164 |
---|---|
Publisher: | O'Reilly Media, Incorporated |
Publication date: | 10/01/2017 |
Pages: | 298 |
Product dimensions: | 6.90(w) x 9.10(h) x 0.70(d) |
About the Author
Paul Bakker is a software architect for Luminis Technologies. His current focus is on building modular enterprise applications and the cloud. He believes that modularity and the cloud are the two main points we have to deal with to bring technology to a next level, and is working on making this possible for main stream software development. Today he is working on educational software focussed on personalised learning for high school students in the Netherlands. He is also responsible for pushing technology forward. Luminis strongly believes in open source and all the technology development they are doing happens in the open source community. Paul is an active contributor on projects such as Amdatu, Apache ACE, JBoss Forge and BndTools. He has a background as trainer on Java related technology and is a regular speaker on conferences.
Table of Contents
Foreword xi
Preface xiii
Part I Introduction to the Java Module System
1 Modularity Matters 3
What Is Modularity? 4
Before Java 9 5
JARs as Modules? 7
Classpath Hell 8
Java 9 Modules 10
2 Modules and the Modular JDK 15
The Modular JDK 16
Module Descriptors 20
Readability 21
Accessibility 22
Implied Readability 23
Qualified Exports 27
Module Resolution and the Module Path 28
Using the Modular JDK Without Modules 30
3 Working with Modules 33
Your First Module 33
Anatomy of a Module 33
Naming Modules 35
Compilation 36
Packaging 37
Running Modules 38
Module Path 40
Linking Modules 41
No Module Is an Island 42
Introducing the Easy Text Example 42
A Tale of Two Modules 44
Working with Platform Modules 48
Finding the Right Platform Module 48
Creating a GUI Module 49
The Limits of Encapsulation 54
Interfaces and Instantiation 55
4 Services 57
Factory Pattern 57
Services for Implementation Hiding 60
Providing Services 60
Consuming Services 62
Service Life Cycle 65
Service Provider Methods 66
Factory Pattern Revisited 68
Default Service Implementations 69
Service Implementation Selection 70
Service Type Inspection and Lazy Instantiation 71
Module Resolution with Service Binding 73
Services and Linking 75
5 Modularity Patterns 79
Determining Module Boundaries 80
Lean Modules 82
API Modules 83
What Should Be in an API Module? 83
Implied Readability 84
API Module with a Default Implementation 88
Aggregator Modules 90
Building a Facade over Modules 90
Safely Splitting a Module 92
Avoiding Cyclic Dependencies 94
Split Packages 94
Breaking Cycles 96
Optional Dependencies 99
Compile-Time Dependencies 100
Implementing Optional Dependencies with Services 104
Versioned Modules 106
Module Resolution and Versioning 107
Resource Encapsulation 109
Loading Resources from a Module 110
Loading Resources Across Modules 111
Working with ResourceBundles 113
6 Advanced Modularity Patterns 115
Strong Encapsulation Revisited 115
Deep Reflection 116
Open Modules and Packages 118
Dependency Injection 121
Reflection on Modules 124
Introspection 124
Modifying Modules 125
Annotations 127
Container Application Patterns 128
Layers and Configurations 129
Classloading in Layers 132
Plug-in Architectures 137
Container Architectures 142
Resolving Platform Modules in Containers 148
Part II Migration
7 Migration Without Modules 153
The Classpath Is Dead, Long Live the Classpath 154
Libraries, Strong Encapsulation, and the JDK 9 Classpath 155
Compilation and Encapsulated APIs 157
Removed Types 160
Using JAXB and Other lava EE APIs 162
The jdk.unsupported Module 165
Other Changes 167
8 Migration to Modules 169
Migration Strategies 170
A Simple Example 170
Mixing Classpath and Module Path 172
Automatic Modules 173
Open Packages 177
Open Modules 179
VM Arguments to Break Encapsulation 180
Automatic Modules and the Classpath 180
Using jdeps 184
Loading Code Dynamically 187
Split Packages 189
9 Migration Case Study: Spring and Hibernate 191
Getting Familiar with the Application 192
Running on the Classpath with Java 9 197
Setting Up for Modules 198
Using Automatic Modules 199
Java Platform Dependencies and Automatic Modules 201
Opening Packages for Reflection 201
Fixing Illegal Access 202
Refactor to Multiple Modules 204
10 Library Migration 207
Before Modularization 208
Choosing a Library Module Name 209
Creating a Module Descriptor 211
Updating a Library with a Module Descriptor 214
Targeting Older Java Versions 215
Library Module Dependencies 216
Internal Dependencies 216
External Dependencies 220
Targeting Multiple Java Versions 221
Multi-Release JARs 221
Modular Multi-Release JARs 224
Part III Modular Development Tooling
11 Build Tools and IDEs 227
Apache Maven 227
Multimodule Projects 229
EasyText with Apache Maven 230
Running a Modular Application with Apache Maven 234
Gradle 235
IDEs 235
12 Testing Modules 237
Blackbox Tests 238
Blackbox Tests with JUnit 240
Whitebox Tests 243
Test Tooling 247
13 Scaling Down with Custom Runtime Images 249
Static Versus Dynamic Linking 250
Using jlink 252
Finding the Right Service Provider Modules 256
Module Resolution During Linking 257
Jlink for Classpath-Based Applications 258
Reducing Size 259
Improving Performance 261
Cross-Targeting Runtime Images 262
14 A Modular Future 263
OSGi 264
Java EE 266
Microservices 267
Next Steps 268
Index 269