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

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

问题描述

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

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.

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

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.

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

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

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

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

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

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

推荐答案

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

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.

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

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

在大多数情况下,将 module-info 引入您的 war 部署只会导致部署问题,因为 JDK 可能会尝试以与应用服务器其他部分不同的方式加载它.或者它甚至没有什么不同,因为大多数应用服务器都有用于加载 jars 和 & 的自定义逻辑.类.

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.

今天的一些应用服务器已经实现了某种模块化,比如 OSGi(GlassFish, Liberty) 或 jboss-modules (Wildfly)但此时拼图仍然存在一些限制,无法在其上运行此类模块化系统.

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.

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

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 文件的 Java 9 模块化是否也是如此?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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