WAR 9文件的Java 9模块化也是如此吗? [英] Is Java 9 modularity for WAR files as well?

查看:121
本文介绍了WAR 9文件的Java 9模块化也是如此吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java EE 7应用程序服务器,特别是Servlet 3.1容器应该允许我们部署包含Web应用程序的WAR文件。 WAR文件本质上是一个带有部署描述符( web.xml )的JAR以及其他几个元素。



另一方面,Java 9引入了模块化JAR文件的概念,即带有模块描述符的JAR( module-info.class )根据项目Jigsaw制作模块。



那么,WAR文件是否也包含模块描述符并制作模块化WAR文件?



是否已有应用程序服务器能够接受模块化WAR文件的部署?



一般来说,servlet的未来是什么根据Java 9模块化的容器和WAR文件?

解决方案

目前Java EE和java 9(jigsaw)之间没有链接模块。
未来的Java EE版本可能会引入有关如何与jigsaw模块交互的规范定义行为。



此时所有应用服务器在运行时都以类路径模式运行在JDK9上实际上意味着他们不使用拼图。



在大多数情况下,将war-deploy引入模块信息只会导致部署问题,因为JDK可能会尝试加载它以与app服务器的其他部分不同的方式。或者它甚至无法发挥作用,因为大多数应用服务器都有自定义逻辑来加载jar和amp;今天的一些应用服务器已经实现了某种模块化,如OSGi(GlassFish,Liberty)或jboss-modules(Wildfly)
但是在这次jigsaw仍然有一些限制,能够在它上面运行这样的模块化系统。



所以简而言之,直到EE规范(可能是9+)更新以描述EE部署应如何在启用jigsaw的运行时上运行,这种部署的行为方式没有官方方式。
在此之前,每个应用服务器都可以为它实现一些自定义支持,但它不会是标准的。


A Java EE 7 application server, and specifically a Servlet 3.1 container should allow us to deploy a WAR file that contains a web application. And a WAR file is essentially a JAR with deployment descriptor (web.xml) and couple of other elements.

On the other hand, Java 9 introduces a notion of modular JAR file, that is, a JAR with module descriptor (module-info.class) which makes a module in terms of project Jigsaw.

So, can a WAR file contain a module descriptor as well and make a "modular WAR file"?

Are there already application servers capable of accepting deployment of a "modular WAR file"?

Generally what is the future of servlet containers and WAR files in terms of Java 9 modularity ?

解决方案

Currently there are no links between Java EE and java 9(jigsaw) modules. Future Java EE releases might introduce spec defined behavior on how to interact with jigsaw modules.

At this point all app servers run in "classpath mode" when running on JDK9 which in practice mean they do not utilize jigsaw.

In most cases introducing module-info to your war deployment can only cause deployment issues as JDK might try to load it in different way than other parts of the app server. Or it could not even make a difference as most app servers have custom logic for loading jars & classes.

Some application servers out there today already implement some kind of modularity such as OSGi(GlassFish, Liberty) or jboss-modules (Wildfly) But at this time jigsaw still has some limitations to be able to run such modular systems on top of it.

So in short, until there is EE spec (probably 9+) that is updated to describe how EE deployments should run on jigsaw enabled runtime there is no "official" way on how such deployment should behave. Until such time, each app server can implement some custom support for it but it wont be standard.

这篇关于WAR 9文件的Java 9模块化也是如此吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆