Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Democamp - Munich - Java9

5.503 Aufrufe

Veröffentlicht am

Short intro to Java9 Modules

Veröffentlicht in: Software
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

Democamp - Munich - Java9

  1. 1. Java9 Modules Tom Schindl <tom.schindl@bestsolution.at> Twitter: @tomsontom Blog: http://tomsondev.bestsolution.at Website: http://www.bestsolution.at
  2. 2. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 About Tom ‣ CTO BestSolution.at Systemhaus GmbH ‣ Eclipse Committer ‣ e4 ‣ Platform ‣ EMF ‣ Project lead ‣ e(fx)clipse ‣ Twitter: @tomsontom ‣ Blog: tomsondev.bestsolution.at ‣ Corporate: http://bestsolution.at
  3. 3. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Targets of Java9 Modulesystem ‣ Split up rt.jar in smaller junks ‣ Avoids further introduction of cross-references ‣ Allows smaller Java-Runtimes (eg for IoT-Devices, …) ‣ Restrict Access to internal APIs (eg com.sun.misc.Unsafe) ‣ Allow developers to adopt it for their code as well
  4. 4. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ The Implementation ‣ OSGi Module System is built upon classloaders ‣ Java9 Module System is implemented at the VM Level
  5. 5. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ The Implementation ‣ OSGi Module System is built upon classloaders ‣ Java9 Module System is implemented at the VM Level OSGi foo-1.0.0 (BundleLoaderClassLoader@f1) bar-1.0.0 (BundleLoaderClassLoader@b1)
  6. 6. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ The Implementation ‣ OSGi Module System is built upon classloaders ‣ Java9 Module System is implemented at the VM Level OSGi foo-1.0.0 (BundleLoaderClassLoader@f1) bar-1.0.0 (BundleLoaderClassLoader@b1) Java9 foo-1.0.0 (AppClassloader@A1) bar-1.0.0 (AppClassloader@A1)
  7. 7. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Dependency definition ‣ OSGi uses custom MANIFEST.MF entries Require-Bundle and Import-Package ‣ Java9 uses module-info.java and directive requires
  8. 8. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Dependency definition ‣ OSGi uses custom MANIFEST.MF entries Require-Bundle and Import-Package ‣ Java9 uses module-info.java and directive requires Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: bar Require-Bundle: foo Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: bar Import-Package: foo OSGi
  9. 9. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Dependency definition ‣ OSGi uses custom MANIFEST.MF entries Require-Bundle and Import-Package ‣ Java9 uses module-info.java and directive requires Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: bar Require-Bundle: foo Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: bar Import-Package: foo OSGi module bar { requires foo; } Java9
  10. 10. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Access Restrictions ‣ OSGi uses custom MANIFEST.MF entry Export-Package ‣ Java9 use module-info.java and directive exports
  11. 11. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Access Restrictions ‣ OSGi uses custom MANIFEST.MF entry Export-Package ‣ Java9 use module-info.java and directive exports Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: foo Export-Package: foo OSGi
  12. 12. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Access Restrictions ‣ OSGi uses custom MANIFEST.MF entry Export-Package ‣ Java9 use module-info.java and directive exports Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: foo Export-Package: foo OSGi module foo { exports foo; } Java9
  13. 13. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Services ‣ OSGi has eg Declarative Service Components and the BundleContext to lookup
  14. 14. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Services ‣ OSGi has eg Declarative Service Components and the BundleContext to lookup Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: bar Require-Bundle: foo Service-Component: OSGI-INF/mycomponent.xml <?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"> <implementation class="bar.BarService"/> <service> <provide interface="foo.Service"/> </service> </scr:component> Provider
  15. 15. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Services ‣ OSGi has eg Declarative Service Components and the BundleContext to lookup Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: bar Require-Bundle: foo Service-Component: OSGI-INF/mycomponent.xml <?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"> <implementation class="bar.BarService"/> <service> <provide interface="foo.Service"/> </service> </scr:component> Provider BundleContext ctx = getContext(cl); ServiceReference<Service> ref = 
 ctx.getServiceReference(Service.class); Service s = ctx.getService(ref); Consumer
  16. 16. (c) BestSolution.at - Licensed under Creative Commons Attribution-NonCommerical-ShareAlike 3.0 Java9 Modules vs OSGi ‣ Service ‣ Java9 uses module-info.java and ServiceLoader for the lookup module bar { requires foo; provides foo.Service with bar.BarService; } Provider module foo { requires foo; uses foo.Service; } Consumer ServiceLoader<GreetService> l = ServiceLoader.load(Service.class); Service s = l.iterator().next();

×