Reputation: 838
IBM Bluexmix automatically configures bound services(https://console.ng.bluemix.net/docs/runtimes/liberty/autoConfig.html)
This results in having dataSource entry in the server.xml (https://console.ng.bluemix.net/docs/services/SQLDB/index.html#SQLDB). It looks like this:
<dataSource id='db2-mydb' jdbcDriverRef='db2-driver' jndiName='jdbc/mydb'
statementCacheSize='30' transactional='true'>
<properties.db2.jcc databaseName='${cloud.services.mydb.connection.db}'
id='db2-mydb-props'
password='${cloud.services.mydb.connection.password}'
portNumber='${cloud.services.mydb.connection.port}'
serverName='${cloud.services.mydb.connection.host}'
user='${cloud.services.mydb.connection.username}'/>
</dataSource>
The jndiName is jdbs/DBServiceName. I want to customize the jndiName so that I can use it in the application without knowing the db service name. At the same time I also want blueMix to create the properties for me because I don't know the db service name before pushing the code.
EDIT Clarifying the setup on BlueMix
Upvotes: 1
Views: 68
Reputation: 1912
You don't necessarily need to know the JNDI name to be able to use the resource in the application. The Liberty buildpack is doing the auto-configuration, but there is also a Liberty feature cloudAutowiring-1.0 that will help you look up the resources if there is only one corresponding instance of the service bound to the app.
Check out these two sample apps:
Upvotes: 2