参数化 EAR
我想为部署在 Glassfish 服务器上的 Java EE 应用程序设置一些只读参数(例如 RMI 注册表主机和端口)。通常执行此操作的位置是部署描述符,但我的问题是它打包在 EAR 中,因此我无法在不更改 EAR 的情况下编辑它。
我需要类似于设置 JDBC 和 JMS 资源的东西,但要简单得多。我可以将配置数据放入数据库表中,但这似乎有点过分了。我可以使用文件资源适配器,但最好可以在 Glassfish 管理控制台中编辑配置。
有没有标准的方法来做到这一点?当应用程序依赖于需要与之通信的外部节点时,如何测试应用程序?我应该把这些参数放在哪里以及如何访问它们?
我最好的猜测是定义外部 JNDI 资源,但是我该将数据放在哪里呢?
更新:这就是我的想法:
如何在 EAR 或 WAR 之外存储 Java EE 配置参数?
所以问题是:如何在 Glassfish 中执行此操作?
I would like to set some read-only parameters (eg. an RMI registry host and port) to a Java EE application deployed on a Glassfish server. The usual place to do this would be the deployment descriptor, but my problem is that it is packaged in the EAR, so I cannot edit it without changing the EAR.
I need something similar to setting JDBC and JMS resources, but much simpler. I could put the configuration data in a database table but that seems to be overkill. I could use the File Resource Adapter, but it would be best if I could edit the configuration in the Glassfish Admin Console.
Is there a standard way to do this? How do you test your applications when they depend on external nodes they need to be communicating with? Where shall I put these parameters and how can I access them?
My best guess was to define external JNDI resources, but then where do I put the data?
UPDATE: this is what I was thinking of:
How can I store Java EE configuration parameters outside of an EAR or WAR?
So the question is: how do I do this in Glassfish?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过几个小时的谷歌搜索,我找到了答案!这并不简单,但幸运的是非常容易。这是:
http://www.mentby.com/glassfish/custom-resource-work-when-looking-it-up-but-not-with-injection.html
创建自定义资源名为“value”的属性。像这样:
替代文本 http://img231.imageshack.us/img231/8237/jndicustomresource .png
然后从 EJB 访问这个名称/值非常容易
:
After a few hours of googling I found the answer! It's not trivial, but luckily very easy. Here it is:
http://www.mentby.com/glassfish/custom-resource-work-when-looking-it-up-but-not-with-injection.html
Create a Custom Resource on the Admin Console, and add a Property called "value". Like this:
alt text http://img231.imageshack.us/img231/8237/jndicustomresource.png
Then accessing this name/value is really easy from the EJB:
Which prints