在JBoss AS7独立部署中加载第三方JAR的最佳做法? [英] Best Practice for loading 3rd party JARs in JBoss AS7 standalone deployment?

查看:231
本文介绍了在JBoss AS7独立部署中加载第三方JAR的最佳做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JBoss-as-7.0.x独立部署中加载第三方JAR的最佳做法是什么?



我尝试过:


  1. 将每个JAR部署为独立模块,自己的module.xml解析器;

  2. 在WAR的WEB-INF / lib目录中部署JAR;

  3. 和共享的任何JAR的foo.ear / lib目录多个WAR

上面介绍的一个明显的优点是在部署时间比apprach 2.和方法3减少了内存占用。要保持一个JAR需要在module.xml中明确定义的每个依赖关系来维护,而且对于大量的第三方库来说,它似乎不太可维护。

解决方案

对于部署私有的较小的依赖关系,请将您的 WEB-INF / lib c $ c> .war ,就是这样。如果你使用的Maven对于< compile />范围。



对于要在多个应用程序之间共享的大型,复杂的依赖关系或依赖关系,请使用选项(4):



将每个逻辑库(例如OpenJPA或Log4J)部署为一个模块,包括其api和impl jar以及其他AS7模块尚未提供的任何依赖JAR。如果已经有一个模块添加了依赖关系,而不是在模块中添加一个JAR。如果几个不同的库共享一些常见的依赖关系,将它们拆分成模块,并将它们作为模块依赖关系添加到 module.xml 中。



使用 jboss-deployment-structure.xml 如果没有自动检测到模块的依赖关系,则可以使用 .war / .ear 自动加载。



我发现这是一个中到低的方法,效果很好。在将部分内容转移到部署中的 WEB-INF / lib 之前,这是比Java EE标准要做的更麻烦的事情。它可以加速重新部署,并通过减少类/版本冲突来节省大量的部署/测试时间。



您可以使用Maven和maven依赖插件来生成模块如果你愿意做一些工作,已经包括了传递依赖关系。您可以在我为AS 7中的EclipseLink集成编写的模块中看到一个示例。我可以自动创建AS7模块。


What is the best practice for loading 3rd party JARs in JBoss-as-7.0.x standalone deployment?

I have tried:

  1. deploying each JAR as an independent module with it's own module.xml desriptor;
  2. deploying the JARs in the WEB-INF/lib directory of a WAR;
  3. and the foo.ear/lib directory for any JARs shared across multiple WARs.

The obvious advantage to approach 1. above is the reduced memory footprint at deploy time over apprach 2. and approach 3. However it seems to be pretty arduous to maintain as each dependency that a JAR has needs to be explicitly defined in the module.xml which doesn't seem very maintainable with large numbers of 3rd party libraries.

解决方案

For smaller dependencies that're private to a deployment, keep 'em in WEB-INF/lib in your .war, that's what it's for. If you're using Maven that should be pretty much automatic and transparent for anything in the <compile/> scope.

For big, complex dependencies or dependencies that'll be shared between several apps, use option (4):

Deploy each logical library (like "OpenJPA" or "Log4J") as a module, including its api and impl jars and any dependency JARs that aren't already provided by other AS7 modules. If there's already a module add a dependency on it rather than adding a JAR to your module. If several different libraries share some common dependencies, split them out into modules and add them as module dependencies in module.xml.

Use jboss-deployment-structure.xml to have your deployment .war / .ear / whatever declare a dependency on the module if it isn't autodetected and autoloaded.

I find this to be a medium-to-low-hassle approach that works well. It's more hassle than dumping everything into WEB-INF/lib inside the deployment, which is the Java EE standard thing to do. It speeds redeploys and it saves lots of deploy/testing time by reducing class/version conflicts.

You can use Maven and the maven-dependency-plugin to produce modules with the transitive dependencies already included if you're willing to do a bit of work. You can see one example of that in a module I wrote for EclipseLink integration in AS 7. I automate the creation of AS7 modules whenever possible.

这篇关于在JBoss AS7独立部署中加载第三方JAR的最佳做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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