动态传递JNDI名称 [英] Passing the JNDI name dynamically

查看:124
本文介绍了动态传递JNDI名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多Web连接服务器,它们的数据库连接使用不同的JNDI名称,因此我必须为每个服务器构建许多Ears文件.我想做这样的事情:

I have a lot of Websphere servers with different JNDI name of my DB connection so I have to build many ears files for each server. I'd like to do something like this:

<bean id="dbDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="${SPECIFIC_JNDI_NAME}"/>
</bean>

如何创建此SPECIFIC_JNDI_NAME变量?

How can I create this SPECIFIC_JNDI_NAME variable?

推荐答案

正确的Java EE方法是在代码中使用资源引用,例如:java:comp/env/jdbc/myDSRef,然后在执行过程中将此资源引用绑定到实际的JNDI名称安装过程.

The proper Java EE way to do it, is using resource references in your code like: java:comp/env/jdbc/myDSRef, then this resource reference is bind to actual JNDI name during the installation process.

您可以通过@Resource标记定义引用,也可以在部署描述符中输入条目(web.xmlejb-jar.xml).

You either define references via @Resource tag, or entry in the deployment descriptor (web.xml or ejb-jar.xml).

您可以通过管理控制台,wsadmin安装脚本或放置在WEB-INF文件夹中的ibm-web-bnd.xml文件将其映射到JNDI名称.

You map it to the JNDI name via admin console, wsadmin installation script, or ibm-web-bnd.xml file placed in the WEB-INF folder.

可以在Spring中使用引用.

It is possible to use references with Spring.

这篇关于动态传递JNDI名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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