是否可以从JBoss容器中部署的所有.war文件中读取属性文件 [英] Is it possible to read a properties file from all .war files deployed in a JBoss container

查看:218
本文介绍了是否可以从JBoss容器中部署的所有.war文件中读取属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法将.war部署到Jboss Web容器中,该容器包含并读取位于/ META-INF / groupid-dir / artifactid-dir /

I've managed to deploy a .war to the Jboss web container containing and read the pom.properties located under /META-INF/groupid-dir/artifactid-dir/

要访问该文件,我在同一个战争中的JSP中使用了以下代码:

To access the file I've used the following code inside a JSP in the same war:

ServletContext servletContext = getServletConfig().getServletContext(); 
InputStream in = servletContext.getResourceAsStream("META-INF/maven/groupid-dir/artifactid-dir/pom.properties");

这很好用。但我希望能够从容器中部署的ALL .war动态读取pom.propertes。这是可能的还是我只能访问我的jsp的一个战争持有者的上下文?

This works just fine. But I want to be able to dynamically read pom.propertes from ALL .war deployed in the container. Is this possible or do I only have access to the context for the one war holder my jsp?

-mb

推荐答案

您只能查找当前类路径中的资源。 Web容器的正常操作是为每个已部署的工件创建特定的类路径,而无需访问容器中部署的其他工件。

You can only look for resources in your current classpath. The normal operation of a web container is to create a specific classpath for each deployed artifact without access to the other artifacts deployed in the container.

这对于避免工件非常重要使用foo-1.0.jar的a不会意外地使用与工件B一起部署的foo-0.9.jar。

This is very important to avoid artifact A which uses foo-1.0.jar to not accidentially use foo-0.9.jar which is deployed with artifact B.

因此,您需要向容器寻求帮助。这反过来意味着您需要编写特定于容器的代码来执行此操作。这将使您依赖供应商 - 您可能不希望这样。

Hence you will need ask the container for help. This in turn mean you need to write container specific code to do so. This will make you vendor dependent - you may not want that.

这篇关于是否可以从JBoss容器中部署的所有.war文件中读取属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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