early days of software architectures, many designers and practitioners often stressed the idea of modular code. Clearly, it makes sense to break up software services or APIs into modules; however, depending on who you talk to, the word module has different meanings to different people. For example, developers using Apache Maven build tools will often view jar artifacts as modules, while some would argue that packages within artifacts are also modules. So what does the word “module” mean in the Java world?
In this chapter, yoursquo;ll get to explore what modularity means for the new Java 9 platform. Yoursquo;ll also learn the Java platform module system (JPMS) in the context of JavaFX applications. This chapter is a gentle introduction to Java 9rsquo;s module system with common use case scenarios such as using a module as a library dependency.
Having said this, I will not be going into great detail covering every modularity use case (believe me, there are quite a few of them). Even as of this writing, there are ongoing discussions regarding other use cases, possibly out of the intended scope. For example, there are still ongoing discussions on the concept of automatic modules and how modules should be named. Despite the back and forth from expert groups and industry leaders relating to missing features versus scoped requirements, I trust the Java community will come to a (well-intended) consensus on a robust modular system that will satisfy most use cases out in the wild. To find out more on the topic of Java 9 Jigsaw, I have listed JSRs, books, and links in the appendix of this book.
As a general disclaimer, especially relating to the new Java 9rsquo;s platform module system, I will caution you with the following.
■ Disclaimer By the time you read this book, Java 9rsquo;s module system will be released. Since Java 9rsquo;s module system is new, the language specifications, APIs, terminologies, and concepts are subject to change. This chapter was written using Java 9rsquo;s early access edition.
Here is a list of sections to follow when reading this chapter on Java 9rsquo;s module system. If you already know the background about Java 9rsquo;s module system and its history, you can skip right to the section called “Getting Started.”
- What is Project Jigsaw?
- History (pre-Java 9)
- Getting Started
- Conclusion
copy; Carl Dea, Gerrit Grunwald, Joseacute; Pereda, Sean Phillips and Mark Heckler 2017 47
C. Dea et al., JavaFX 9 by Example, DOI 10.1007/978-1-4842-1961-4_2
ChAPTer 2 JAvAFX And JIgSAw
What Is Project Jigsaw?
Java modularity, aka “Project Jigsaw,” was an effort to enable developers to partition and encapsulate code in a more manageable manner on the Java platform. By way of partitioning code into modules, application code will be more loosely coupled instead one monolithic application. With good encapsulation, modules can be defined to expose (export) APIs to other modules safely. Javarsquo;s new module system will also be backward compatible to code and libraries prior to Java 9 (non-modular code). Not only are partitioning and encapsulating code very good principles, there are other additional benefits, as you will see later.
According to Mark Reinhold, he summarizes JSR 376 (Project Jigsaw):
The overall goal of this JSR is to define an approachable yet scalable module system for the Java Platform. It will be approachable, i.e., easy to learn and easy to use, so that developers can use it to construct and maintain libraries and large applications for both the Java SE and Java EE Platforms. It will be scalable so that it can be used to modularize the Java SE Platform itself, and its implementations.
Mark Reinhold Chief Architect of the Java Platform Group at Oracle, April 1, 2015
Benefits
According to the official web site of project Jigsaw (http://openjdk.java.net/projects/jigsaw) the following are the primary goals and benefits of a modular system on the Java platform:
- Make the Java SE platform, and the JDK, more easily scalable down to small computing devices
- Improve the security and maintainability of Java SE platform implementations in general, and the JDK in particular
- Enable improved application performance
- Make it easier for developers to construct and maintain libraries and large applications, for both the Java SE and EE platforms
To achieve these goals, we propose to design and implement a standard module system for the Java SE platform and to apply that system to the platform itself, and to the JDK. The module system should be powerful enough to modularize the JDK and other large legacy code bases, yet still be approachable by all developers.
Project Jigsaw site December 21, 2016
As mentioned relating to partitioning applications these benefits can also lead to scaling down applications to fit into smaller computing devices such as ARM based computers. Having modular code will also help the maintenance and security on the Java SE and Java EE platforms as microservices becomes the norm when developing on cloud and container-based application environments.
Since modules make way for reliable configuration building, applications would occupy smaller footprints, thus increasing the performance in areas relating to memory and load times. An example of this is a modular JavaFX applicationrsquo;s start-up speed boost due to a smaller set of modules loaded. Prior to Java 9, applications were developed and packaged with the entire Java runtime. These apps had to load many unused libraries such as corba or sql packages.
ChAPTer 2 JAvAFX
剩余内容已隐藏,支付完成后下载完整资料
在软件体系结构的早期,许多设计者和实践者经常强调模块化代码的思想。显然,将软件服务或API分解成模块是有意义的,但是,取决于您与谁交谈,这个模块对不同的人有不同的含义。例如,使用Apache Maven开发者构建工具经常会认为罐文物作为模块,虽然有人会说,包内的文物也模块。那么,“指的是在java世界模块”吗?
在这一章中,你将探索模块化为新的java 9平台意味着什么。您还将学习java平台的模块化系统(jpms)在JavaFX应用程序上下文。本章介绍java 9的模块系统与普通的使用情况,如使用一个模块作为一个库的依赖关系。
话虽如此,我不会详细介绍每一个模块化用例(相信我,有相当多的)。即使在本文写作中,仍有关于其他用例的讨论,可能超出了预期的范围。例如,目前仍在讨论自动模块的概念以及如何命名模块。尽管来回从专家组和行业领袖与缺失的功能与范围的要求,我相信java社区会来的(善意的)在一个强大的模块化系统,可以满足大多数情况下使用在野外的共识。了解更多关于java 9拼图的话题,我列出了JSR,书籍,在这本书的附录中的链接。
作为一个通用的免责条款,特别是有关新的java 9平台模块的系统,我会提醒你的。
■声明你读到这本书的时候,java 9的模块系统将被释放。由于java 9模块系统是新的,语言规范、API、术语和概念,如有变更。本章是用java写的9年代早期访问版。
这里是一个遵循阅读本章对java 9的模块系统的部分名单。如果你已经知道了关于java的背景9模块系统和它的历史,你可以跳过权利的部分称为“开始”。
什么是项目拼图?
bull;历史(预java 9)
bull;入门
bull;结论
copy;Carl Dea,Gerrit Grunwald,乔eacute;佩雷德、Sean Phillips和Mark Heckler 2017 47
C. Dea等人,JavaFX 9的例子,我10.1007/978-1-4842-1961-4_2
2章JavaFX和拼图
什么是项目拼图?
java模块,又名“项目拼图,“是为了使开发人员的划分和封装的代码更易于管理的方式对java平台。通过将代码划分为模块,应用程序代码将更加松散耦合,而不是单一的应用程序。具有良好的封装性,可以将模块定义为安全地将(导出)API公开给其他模块。java的新模块系统也将向后兼容的代码和库,java 9之前(非模块化的代码)。分区和封装代码不仅是非常好的原则,还有其他的好处,如您稍后将看到的。
根据Mark Reinhold的说法,他总结了JSR 376(Jigsaw项目):
本规范的总体目标是定义一个平易近人的可扩展的java平台的模块系统。这将是平易近人的,即,易学易用,使开发人员可以使用它来构建和维护图书馆和大型应用程序的java SE和java EE平台。这将是可扩展的,它可以用模块化的java SE平台本身及其实现。
Mark Reinhold总建筑师在甲骨文的java平台组,2015年4月1日
效益
根据项目拼图的官方网站(http://openjdk.java.net/projects/jigsaw)以下是java平台上的模块化系统的主要目标和效益:
bull;使java SE平台和JDK,更容易扩展到小型计算设备
bull;提高安全和java SE平台实现一般的可维护性,特别是在JDK
bull;启用改进的应用程序性能
bull;使开发人员构建和维护图书馆和大型的应用程序更加容易,对于java SE和EE平台
为了实现这些目标,我们提出并实施了java SE平台标准模块系统和应用系统平台本身的设计,并对JDK。该模块系统应该足够强大的模块化JDK和其他大型遗留代码库,但仍然是平易近人的开发商。
项目拼图网站2016年12月21日
正如提到的分区应用程序一样,这些好处也会导致缩小应用程序,以适应更小的计算设备,如基于ARM的计算机。具有模块化的代码也将有助于维护和保障对java SE和java EE平台精卫成为常态时,发展中国家在云基础应用环境的容器。
由于模块为可靠的配置构建让路,应用程序将占用更小的内存,从而提高与内存和负载时间相关的性能。这方面的一个例子是一个模块化的JavaFX应用程序的启动速度的提升,由于较小的一组模块加载。java 9之前,应用程序开发和包装整个java运行时。这些应用程序必须加载许多未使用的库,如CORBA或SQL包。
2章JavaFX和拼图
额外的好处时,模块化的java代码(java 9)被列为java增强方案:
bull;模块运行时的图像(JEP 220 http://openjdk.java.net/jeps/220)
一个javabull;模块连接器(JEP 282 http://openjdk.java.net/jeps/282)
bull;提前编译(JEP 295 http://openjdk.java.net/jeps/295)
喷射220为java SE平台模块运行时的图像增强方案。建筑师有重组整个java运行平台如目录和核心库。重构运行时平台将有助于提高安全性、性能和可管理性。例如,图书馆如rt.jar,tools.jar,和jfxrt.jar将不再是可访问的,但都是模块坏了。
新的java 9是JLINK,java链接器(卷282)。Jlink是工具组装和连接模块和它们的依赖到一个自定义运行时图像构建应用程序。创建自定义运行库映像,java链接器应用在运行时如何被连接结构(卷220)。换句话说,两作业输入外围服务基本上是在锁步彼此。
最后3个作业输入外围服务提到JEP 295,提前编译。这是更好地称为AOT编译。虽然它被认为是实验性的,AOT编译器可以把java代码到本地代码的Linux操作系统。这有一个很好的优势,当环境没有java运行时安装。另一个优点是速度。因为代码是静态编译的,没有必要有JIT(Just-In-Time)编译或热身。此功能将用于小型设备或高效的服务器(网络设备)。当你读到这里时,AOT编译将支持
流行的操作系统。
这三个重要的java增强建议一起工作,你会开始看到基于java的应用程序建立更简单,更薄,速度更快,和本地。
缺点
虽然设计模块化代码有很多好处,但也存在一些缺点。有些缺点如下:
bull;定义模块和依赖项时的额外复杂性。
bull;没有标准的项目结构为多个模块,因为它涉及到各种编译工具和集成开发环境。
bull;当混合遗产非模块化的代码模块代码,路径和模块路径在起作用。调试代码和解析依赖项可能更困难。
bull;遗留的依赖可能不会经过改写成为一个java 9模块,可以向前或向后兼容性风险。
java 9的迁移路径
现在你已经读到关于新的java平台模块系统的优点和缺点,你可能仍然在篱笆上,因为未知的风险。也许你认为它还是太新了。为了缓解任何潜在的焦虑,Oracle来帮助您创建迁移遗留应用java java 9个好向导。努力争取吧。
迁移指南位于这里:https://docs.oracle.com/javase/9/migrate。另外,你应该看看在JDK 9这里重要的变化:https://docs.oracle.com/javase/9/whatsnew/toc.htm。
该指南是一个非常详细的解释了如何使用java 9平台模块和第三方库。迁移指南还谈到了一个分析工具称为jdeps。
2章JavaFX和拼图
该jdeps分析工具
当运行jdeps对您的应用程序代码,该工具会检查代码以确定它是否依赖于过时的依赖或JDK内部API。例如,分析工具将建议应替换的api。建议提供一个使用包从COM代码替换。太阳,太阳。杂项。*,例如,如果你创建了一个java应用unmodularized在引用非公开包如COM。太阳。*,该jdeps工具可以使用提供了一个可选择的模块。这里是输出后调用jdeps工具对java编译的类文件8。
$ jdeps - CP。COM / jfxbe / HelloWorld / HelloWorld.class
helloworld.class -gt; java.base
helloworld.class -gt; javafx.base
helloworld.class -gt; javafx.controls
helloworld.class -gt; javafx.graphics
helloworld.class -gt; jdk.httpserver
com.jfxbe.helloworld -gt; com.sun.net.httpserver jdk.httpserver com.jfxbe.helloworld -gt;“java.base com.jfxbe.helloworld -gt; javafx.application javafx.graphics com.jfxbe.helloworld -gt; javafx.collections javafx.base com.jfxbe.helloworld -gt; javafx.event javafx.base com.jfxbe.helloworld -gt; javafx.scene javafx.graphics com.jfxbe.helloworld -gt; javafx.scene.control javafx.controls com.jfxbe.helloworld -gt; javafx.stage javafx.graphics
分析的输出显示的HelloWorld应用平台模块的概要和细节。类文件。你会注意到com.sun.net.httpserver可以在jdk.httpserver模块。假设您的应用程序依赖于类com.sun.net.httpserver.httpserver,转向java模块的建议意味着你将需要创建一个module-info.java文件要求jdk.httpserver模块作为一个依赖。
让我们看看另一个例子,使用jdeps工具对java 9模块化应用程序JAR文件看看。
下面是通过显示其依赖信息来分析模块化JAR应用程序的示例。
V helloworld.jar jdeps美元
bull;摘要或S打印依赖关系摘要。
bull;冗长或V打印所有类级别的依赖项。
这是运行后jdeps输出:
$ jdeps -v mlib/com.jfxbe.helloworld.jar
com.jfxbe.helloworld
[file:///Users/cpdea/JavaFX9byExample/Code/jfx9be/chap02/helloworld/mlib/com.jfxbe.
helloworld.jar] requires mandated java.base (@9-ea) requires javafx.base (@9-ea) requires javafx.controls (@9-ea) requires javafx.graphics (@9-ea) requires jdk.httpserver (@9-ea)
ChAPTer 2 JAvAFX And JIgSAw
com.jfxbe.helloworld -gt; java.base com.jfxbe.helloworld -gt; javafx.base com.jfxbe.helloworld -gt; javafx.controls com.jfxbe.helloworld -gt; javafx.graphics com.jfxbe.helloworld -gt; jdk.httpserver com.jfxbe.helloworld.HelloWorld -gt; com.jfxbe.helloworld.HelloWorld$1 com.jfxbe. helloworld
com.jfxbe.helloworld.HelloWorld -gt; com.sun.net.httpserver.HttpServer jdk.httpserver com.jfxbe.helloworld.HelloWorld -gt; java.lang.Object java.base com.jfxbe.helloworld.HelloWorld -gt; java.lang.String java.base com.jfxbe.helloworld.HelloWorld -gt; java.lang.Throwable java.base com.jfxbe.helloworld.HelloWorld -gt; javafx.application.Application javafx.graphics com.jfxbe.helloworld.HelloWorld -gt; javafx.collections.ObservableList javafx.base com.jfxbe.helloworld.HelloWorld -gt; javafx.event.EventHandler jav
剩余内容已隐藏,支付完成后下载完整资料
资料编号:[463457],资料为PDF文档或Word文档,PDF文档可免费转换为Word
以上是毕业论文外文翻译,课题毕业论文、任务书、文献综述、开题报告、程序设计、图纸设计等资料可联系客服协助查找。