简体   繁体   English

如何访问部署到IBM WebSphere 6.1的EAR的application.xml文件

[英]How to access application.xml file of an EAR deployed to IBM WebSphere 6.1

I am deploying an EAR file to the IBM WebSpehre server 6.1 - I want to be able to access the EAR application name which is stored in the deployment file under 'display-name'. 我正在将一个EAR文件部署到IBM WebSpehre服务器6.1 - 我希望能够访问存储在“display-name”下的部署文件中的EAR应用程序名称。 Looking through stack overflow posts on related subjects, I've been able to gather that this is possible via the Java MBean API - or IBM's WAS API - Problem is I cannot find a place where these API lists are summarized, ie cannot figure out which one to begin looking at. 通过查看相关主题的堆栈溢出帖子,我已经能够通过Java MBean API或IBM的WAS API收集这个问题 - 问题是我找不到这些API列表汇总的地方,即无法弄清楚哪个一个开始看。 I could hardcode the WAS install location and find the file by looking in the 'installedApps' directory, but this is not dynamic. 我可以通过查看'installedApps'目录来硬编码WAS安装位置并找到该文件,但这不是动态的。

Does anyone have any experience working with these APIs? 有没有人有使用这些API的经验? Any other way to dynamically find the deployed EAR's display name? 还有其他方法可以动态查找已部署的EAR的显示名称吗?

EDIT - I should add that the reason I would like this information is to dynamically load our properties files - that are named by the following convention "EARAppName.properties" - so you see there IS a reasonable 'rationale' behind desiring this information in my application 编辑 - 我应该补充一点,我希望这些信息的原因是动态加载我们的属性文件 - 由以下约定“EARAppName.properties”命名 - 所以你看到在我希望这些信息背后有一个合理的'理由'应用

EDIT 2 - I should also note that this app will always be deployed on a WAS - but in the case that it isnt, a generic non-proprietary solution would be preferred, but not necessary at this moment. 编辑2 - 我还应该注意,这个应用程序将始终部署在WAS上 - 但是如果不是这样,通用的非专有解决方案将是首选,但此时不是必需的。

EDIT 3 - What I want to accomplish: Is there a way to dynamically find the deployed EAR's display name from within the application code? 编辑3 - 我想要完成的任务:有没有办法从应用程序代码中动态查找已部署的EAR的显示名称?

Not a direct answer but wouldn't it be simpler to use an hard coded name for the properties file? 不是一个直接的答案,但是对于属性文件使用硬编码名称会不会更简单? After all, it seems to make sense for a given application to be aware of what file to load. 毕竟,对于给定的应用程序来说,了解要加载的文件似乎是有意义的。 Writing code to read the display-name in a deployment descriptor sounds odd (especially since you, as Application Component Provider , shouldn't rely on something owned by the Application Assembler ). 编写代码来读取部署描述符中的display-name听起来很奇怪(特别是因为你作为Application Component Provider ,不应该依赖Application Assembler拥有的东西)。

If the whole reason for this objective is reading properties files, then I would recommend a different approach. 如果这个目标的全部原因是读取属性文件,那么我会推荐一种不同的方法。

Use WebSphere Shared Library. 使用WebSphere Shared Library。

http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/tcws_sharedlib.html http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/tcws_sharedlib.html

For each deployed EAR have a separate directory containing properties files that needs to be accessed by that EAR. 对于每个部署的EAR,都有一个单独的目录,其中包含需要由该EAR访问的属性文件。

Create shared library entry for each directory containing properties file. 为包含属性文件的每个目录创建共享库条目。

From EAR create shared library reference to required shared library. 从EAR创建共享库引用到所需的共享库。

.

However below links may be of some help to you for your approach: 但是,以下链接可能对您的方法有所帮助:

Managing applications through programming 通过编程管理应用程序

Interface AppManagement 界面AppManagement

I am trying to accomplish the same thing here. 我想在这里完成同样的事情。 I am trying to locate at runtime the ApplicationName found in the META-INF/application.xml. 我试图在运行时找到META-INF / application.xml中找到的ApplicationName。

We use this AppName in our Log4J File Appender to create a proper log file name base on the Application currently logging. 我们在Log4J File Appender中使用此AppName在当前正在记录的应用程序上创建正确的日志文件名。 We have lots of programmers and lots of App and we need to enforce some convention in a framework. 我们有很多程序员和大量的App,我们需要在框架中强制执行一些约定。

I whish I could simply call: 我可以简单地打电话给:

InputStream in = new MyObject().getClass().getResourceAsStream(“META-INF/application.xml”);

I also tried to change the classloader to 'PARENT_LAST/FIRST' and 'Single ClassLoader' but it does not work. 我还尝试将类加载器更改为'PARENT_LAST / FIRST'和'Single ClassLoader',但它不起作用。

I could locate the application.xml on filesystem relative to my war file but I am not sure it would work all the time. 我可以在文件系统上找到相对于我的war文件的application.xml,但我不确定它是否会一直有效。

Is the JMX Api realy the only way? JMX Api真的是唯一的方式吗?

这不是您的应用程序知道的,而是适用于EAR处理工具,包括应用程序服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM