java JBoss SAR 与 EAR/WAR 打包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10355778/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 00:41:12  来源:igfitidea点击:

JBoss SAR vs EAR/WAR packaging

javajbossjmxmbeanssar

提问by nemo

When would I choose to deploy as a JBoss SAR instead of an EAR?

我什么时候会选择部署为 JBoss SAR 而不是 EAR?

This is more of a general question and I'm looking for guidelines that explain the pros and cons of each deployment model and which one is applicable when.

这更像是一个一般性问题,我正在寻找解释每种部署模型的优缺点以及哪种部署模型适用的指南。

回答by CoolBeans

You will build a SAR (service archive) when you want to expand the capabilities of the server. For example, JBoss uses SARs for EJB deployer or messaging. You can create one for your own service monitoring (ie. watch some metrics for one of your custom services). As far as I know SARs are unique to JBoss only.

当您要扩展服务器的功能时,您将构建一个 SAR(服务存档)。例如,JBoss 将 SAR 用于 EJB 部署程序或消息传递。您可以为自己的服务监控创建一个(即,观察您的自定义服务之一的一些指标)。据我所知,SAR 仅适用于 JBoss。

From my personal experience, I once created a SAR to keep track of a web service. I mainly used the service component to keep track of the length of a list of things that the web service component created. This was one way I could poke in the jmx-console and find out some metrics about the incoming requests to the web service.

根据我的个人经验,我曾经创建了一个 SAR 来跟踪 Web 服务。我主要使用服务组件来跟踪 Web 服务组件创建的事物列表的长度。这是我可以进入 jmx-console 并找出有关传入 Web 服务请求的一些指标的一种方式。

SARs are based on JMX specs so it's not difficult to create them. You basically create a standard MBean interface and implement that interface. You will also want to make sure you that you have a jboss-service.xmlfile in the META-INFdirectory.

SAR 基于 JMX 规范,因此创建它们并不困难。您基本上可以创建一个标准的 MBean 接口并实现该接口。您还需要确保目录中有一个jboss-service.xml文件META-INF

On the other hand WARs and EARs are for standard application packaging where you expect the container to manage and process requests for the application. You don't expect the application to be running as an anonymous service component like you do in case of a SAR packaged application.

另一方面,WAR 和 EAR 用于标准应用程序打包,您希望容器在其中管理和处理对应用程序的请求。您不希望应用程序像在 SAR 打包应用程序中那样作为匿名服务组件运行。

Hope this helps!

希望这可以帮助!