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>
How can I create this SPECIFIC_JNDI_NAME variable?
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.
You either define references via @Resource
tag, or entry in the deployment descriptor (web.xml
or ejb-jar.xml
).
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.
It is possible to use references with Spring.