what's not new in modular java!
TRANSCRIPT
![Page 1: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/1.jpg)
What's
notnew
in
modularJava!
Milen Dyankov@milendyankov
Featuring JDK 9 Early Access with Project Jigsaw
senior consultant @Liferay
![Page 2: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/2.jpg)
Think of
not newas in
not new conceptand not as in
not newcar
![Page 3: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/3.jpg)
Whyis it
about timeto start thinkingabout
modularityin Java?
![Page 4: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/4.jpg)
JSR 277JSR 294
JSR 376JEP 200JEP 201JEP 220JEP 260JEP 261
...
2005
2014
![Page 5: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/5.jpg)
![Page 6: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/6.jpg)
Antwerp, Belgium,November 2015
“Survey” at
![Page 7: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/7.jpg)
Whatis
modularity/particularly in Java/
anyway?
![Page 8: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/8.jpg)
"When I use a word," Humpty Dumpty said,
in rather a scornful tone,
"it means just what I choose it to mean - neither
more nor less."
![Page 9: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/9.jpg)
Modularity Maturity Modelproposed by Dr Graham Charters
at the OSGi Community Event 2011
Level 1 Ad Hoc nothing
Level 2 Modules decoupled from artifact
Level 3 Modularity decoupled from identity
Level 4 Loose-Coupling decoupled from implementation
Level 5 Devolution decoupled from ownership
Level 6 Dynamism decoupled from time
![Page 10: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/10.jpg)
Level 1 Ad Hoc nothing
Level 2 Modules decoupled from artifact
Level 3 Modularity decoupled from identity
Level 4 Loose-Coupling decoupled from implementation
Level 5 Devolution decoupled from ownership
Level 6 Dynamism decoupled from time
Level 7 Peter Kriens only available to people who are Peter Kriens
Modularity Maturity Modelproposed by Dr Graham Charters
at the OSGi Community Event 2011
![Page 11: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/11.jpg)
Modularity Maturity Modelproposed by Peter Kriens
in foreword to “Java Application Architecture”
Level 1 Ad Hoc
Level 2 Modules
Level 3 Modularity
Level 4 Loose-Coupling
Level 5 Devolution
Level 6 Dynamism
Unmanaged / chaos
Managing dependencies
Proper isolation
Minimize coupling
Service-oriented architecture
![Page 12: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/12.jpg)
Level 1 Monolith
Level 2 Composite
Level 3 Containers
Level 4 Discovery
Level 5 JuServices
Buzzword compliant Modularity Maturity Model
![Page 13: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/13.jpg)
Level 1 Monolith Unaware of own dependencies
Level 2 Composite Aware of infrastructural dependencies
Level 3 Containers Aware of functional dependencies
Level 4 Discovery Aware of functional requirements
Level 5 Adapts to changing requirementsJuServices
Buzzword compliant Modularity Maturity Model
![Page 14: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/14.jpg)
Level 1 Monolith
Level 2 Composite
Level 3 Containers
Level 4 Discovery
Level 5 JuServices
Buzzword compliant Modularity Maturity Model
![Page 15: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/15.jpg)
Level 1 Monolith
Level 2 Composite
Level 3 Containers
Level 4 Discovery
Level 5 JuServices
Buzzword compliant Modularity Maturity Model
![Page 16: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/16.jpg)
Buzzword compliant Modularity Maturity Model
JuServices
Level 1 Monolith
Level 2 Composite
Level 3 Containers
Level 4 Discovery
Level 5
![Page 17: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/17.jpg)
Buzzword compliant Modularity Maturity Model
JuServices
Level 1 Monolith
Level 2 Composite
Level 3 Containers
Level 4 Discovery
Level 5 OSGi
![Page 18: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/18.jpg)
Buzzword compliant Modularity Maturity Model
JuServices OSGi
JSR 376
Level 1 Monolith
Level 2 Composite
Level 3 Containers
Level 4 Discovery
Level 5
![Page 19: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/19.jpg)
Buzzword compliant Modularity Maturity Model
JuServices OSGi
JSR 376
Level 1 Monolith
Level 2 Composite
Level 3 Containers
Level 4 Discovery
Level 5
![Page 20: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/20.jpg)
Whatis
modularity from
application perspective ?
![Page 21: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/21.jpg)
Javaapplication
![Page 22: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/22.jpg)
Javaapplication
Java Platform
Libraries
![Page 23: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/23.jpg)
OS
Gi
![Page 24: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/24.jpg)
There is nothing we can do about it!
OS
Gi
![Page 25: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/25.jpg)
c l a s s l o a d e r s
There is nothing we can do about it!
OS
Gi
![Page 26: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/26.jpg)
c l a s s l o a d e r s
There is nothing we can do about it!
Dynamic multi-layer modular runtime!
OS
Gi
![Page 27: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/27.jpg)
c l a s s l o a d e r s
There is nothing we can do about it!
Dynamic multi-layer modular runtime!
It's so easy, everyone
shouldreleasebundles
(modules)! OS
Gi
![Page 28: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/28.jpg)
“Manypeople claim
OSGi is hard withoutacknowledging that modularizing
applications is the hard part. . . .
JSR 376 will demonstrate that OSGiwas just the messenger and actually not the cause.”
Peter Kriens
![Page 29: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/29.jpg)
JS
R 3
76
![Page 30: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/30.jpg)
JS
R 3
76
Modules arefirst class citizens!
![Page 31: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/31.jpg)
JS
R 3
76
Modules arefirst class citizens!
Nothing to do about it, must use modules!
![Page 32: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/32.jpg)
JS
R 3
76
Modules arefirst class citizens!
Nothing to do about it, must use modules!
It's so easy, everyone
mustreleasemodules!
![Page 33: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/33.jpg)
not new
except nowyou kindahave to
newModularJava SE Platform!
ModularJava SE
Applications!
![Page 34: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/34.jpg)
“A lot of people
will discover that
their babies are not as
modular as they thought”Peter Kriens
![Page 35: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/35.jpg)
Whenis
“keep itsimple!”not enough?
![Page 36: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/36.jpg)
productintermediate
intermediate
material
![Page 37: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/37.jpg)
![Page 38: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/38.jpg)
![Page 39: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/39.jpg)
![Page 40: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/40.jpg)
Product
Entity
EntityEntity
Entity
Entity Entity
Offer
Offer
Offer
Offer
Offer
Offer
Offer
Offer
Offer
Offer
Offer
![Page 41: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/41.jpg)
Application
Artifact
ArtifactArtifact
Artifact
Artifact Artifact
Export
Export
Export
Export
Export
Export
Export
Export
Export
Export
Export
![Page 42: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/42.jpg)
Artifact
OSGi JSR 376
Manifest-Version: 1.0Bundle-SymbolicName: \
com.mycompany.mymodule
...
MANIFEST.MF
module com.mycompany.mymodule {
...
}
module-info.java
Level 2decoupled from
artifact
![Page 43: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/43.jpg)
Buzzword compliant Modularity Maturity Model
JuServices OSGi
JSR 376
Level 1 Monolith
Level 2 Composite
Level 3 Containers
Level 4 Discovery
Level 5
OK!
![Page 44: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/44.jpg)
Artifact
OSGi JSR 376
Manifest-Version: 1.0Bundle-SymbolicName: \
com.mycompany.mymodule
Export-Package: \com.mycompany.mypackage
...
MANIFEST.MF
module com.mycompany.mymodule {
exports com.mycompany.mypackage;
...
}
module-info.java
Export
Level 3 decoupled from
identity
![Page 45: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/45.jpg)
OSGi JSR 376
Manifest-Version: 1.0Bundle-SymbolicName: \
com.mycompany.mymodule
Require-Bundle: \other.module
Import-Package: \com.some.package;version="[2,3)",...
...
MANIFEST.MF
module com.mycompany.mymodule {
requires other.module;
...
}
module-info.java
Artifact
Export
Artifact
Level 3 decoupled from
identity
![Page 46: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/46.jpg)
OSGi JSR 376
Manifest-Version: 1.0Bundle-SymbolicName: \
com.mycompany.mymodule
Require-Bundle: \com.foo
Import-Package: \com.generic.powerplug;version="[2,3)",...
...
MANIFEST.MF
module com.mycompany.mymodule {
requires com.foo;
...
}
module-info.java
Foo
Me
I need power plug!
I need Foo because I know it offers power plugs and I know only Foo
offers power plugs!
Level 3 decoupled from
identity
![Page 47: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/47.jpg)
OSGi JSR 376Level 3 decoupled from
identity
Manifest-Version: 1.0Bundle-SymbolicName: \
com.mycompany.mymodule
Require-Bundle: \com.foo
Import-Package: \com.generic.powerplug;version="[2,3)",...
...
MANIFEST.MF
module com.mycompany.mymodule {
requires com.foo;
...
}
module-info.java
Foo
Me I'm compatible with all 2.x.x
versions!
I expect developer/user to know which version
will work and provide it on module path!
![Page 48: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/48.jpg)
OSGi JSR 376Level 3 decoupled from
identity
Manifest-Version: 1.0Bundle-SymbolicName: \
com.mycompany.mymodule
Export-Package: \com.mycompany.mypackage;\
uses:="com.some.package”
...
MANIFEST.MF
module com.mycompany.mymodule {
exports com.mycompany.mypackage;
requires public other.module;
...
}
module-info.java
Artifact
Artifact
ArtifactExport
Uses
Export
![Page 49: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/49.jpg)
OSGi JSR 376Level 3 decoupled from
identity
Manifest-Version: 1.0Bundle-SymbolicName: \
com.mycompany.devices
Export-Package: \com.mycompany.pc; \
uses:="foo.tools.powerplug”
...
MANIFEST.MF
module com.mycompany.devices {
exports com.mycompany.pc;
requires public foo.tools;
...
}
module-info.java
Me
Consumer
Foo
I used a power plug from Foo! You may need it!
I used somethingfrom Foo tools,
so you now depend on Foo tools
as well!
![Page 50: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/50.jpg)
Buzzword compliant Modularity Maturity Model
JuServices OSGi
JSR 376
Level 1 Monolith
Level 2 Composite
Level 3 Containers
Level 4 Discovery
Level 5
Not fully decoupled from identity!
OK!
![Page 51: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/51.jpg)
OSGi JSR 376Level 4decoupled from implementation
Artifact
Artifact
RequirementNeed toconnectdevice to
power outlet!
CapabilityCan
connectdevice to
power outlet!
RESOLVER
Bundles with custom metadata
Requirements and Capabilities with LDAP like filters
Bundle lifecycle events and listeners
Extender pattern
Nothing OOTB. Use OSGi :)
Probably doable via external resolver dynamic modules and layers
JEE or 3rd party solutions on top of JSR 376 may provide solutions
![Page 52: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/52.jpg)
Buzzword compliant Modularity Maturity Model
JuServices OSGi
JSR 376
Level 1 Monolith
Level 2 Composite
Level 3 Containers
Level 4 Discovery
Level 5
Not fully decoupled from identity!
Some very basic APIs only!
OK!
![Page 53: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/53.jpg)
OSGi JSR 376Level 5
decoupled from ownership & time
JuServices
Artifact
Artifact
REGISTRY
Service
Service
Service
Service
Service registry with metadata
Finding services via LDAP like filters
Service lifecycle, events and listeners
Multiple component frameworks
Whiteboard pattern
Traditional Java ServiceLoader (not dynamic) moved to module descriptor
Alternative: minimal standalone Java applications with external service discovery
![Page 54: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/54.jpg)
Buzzword compliant Modularity Maturity Model
JuServices OSGi
JSR 376
Level 1 Monolith
Level 2 Composite
Level 3 Containers
Level 4 Discovery
Level 5
Not fully decoupled from identity!
Very limited service layer! DIY dynamism!
OK!OK!
Some very basic APIs only!
![Page 55: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/55.jpg)
Does this mean JSR 376got modularity wrong?
![Page 56: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/56.jpg)
When they say
modular Java it means
just what they choose it to mean -
neither more nor less!
![Page 57: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/57.jpg)
JSR 376 solves some issues in Java platform!
Level 5 modularity was never one of them!
Reliable configuration
Strong encapsulation
A scalable Java SE Platform
Greater platform integrity
Improved performance
![Page 58: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/58.jpg)
“... once modularization becomes part of the Java core tool set,
developers will begin to embrace it en-masse,
and as they do so, they will seek more robust
and more mature solutions. Enter OSGi!”
Victor Grazi
![Page 59: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/59.jpg)
Whenan application
needs modularity
at higher level ?
![Page 60: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/60.jpg)
The essence ofmodularity is
Not knowing
![Page 61: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/61.jpg)
1 platform
over 100 apps
over 600 modules
over 2500 μServices
Some examples of how
deals with not knowing
The essence ofmodularity is
Not knowing
![Page 62: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/62.jpg)
Require-Capability: \osgi.contract; \filter:="(&(osgi.contract=JavaJAXRS)(version=2))"
Provide-Capability: \ osgi.contract; \ osgi.contract=JavaJAXRS; \ Uses:= "javax.ws.rs, \
javax.ws.rs.core, \javax.ws.rs.client, \ javax.ws.rs.container, \javax.ws.rs.ext"; \
version:Version=2
Some examples of how
deals with not knowing
The essence ofmodularity is
Not knowing
![Page 63: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/63.jpg)
@Component( immediate = true, property = "javax.portlet.name=other_Portlet"{ }, service = PortletFilter.class)public class MyFilter implements RenderFilter {
...
Some examples of how
deals with not knowing
The essence ofmodularity is
Not knowing
![Page 64: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/64.jpg)
@Component( immediate = true, property = "destination.name=" + MONITORING{ }, service = MessageListener.class{ })public class MonitoringMessageListener ...
@Reference( cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY ) protected synchronized void registerProcessor(
...
Some examples of how
deals with not knowing
The essence ofmodularity is
Not knowing
![Page 65: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/65.jpg)
The essence ofmodularity is
Not knowing
Which enforcesoptimization forPredictability
![Page 66: What's NOT new in Modular Java!](https://reader031.vdocuments.mx/reader031/viewer/2022021919/58739bf91a28ab85438b6a6d/html5/thumbnails/66.jpg)
Which results inapplicationAgility
The essence ofmodularity is
Not knowing
Which enforcesoptimization forPredictability