The Application module gets its respective data-source details from it currently active configuration. The configuration has two means of accessing database. One is the jdbc connection url and the other is jndi name of jdbc datasource. The jdbc connection url will be available in connections.xml of the respective application.
If we want AM to read the datasource string of our choice at runtime, we need to configure the AM property - " jbo.envinfoprovider". By default nothing is configured to it. we will need to implement our CustomEnvInfoProvider and configure it that property. Below is the snippet of the CustomEnvInfoProvider.
---------------------------------------------------------------------------------------------------
package model;
import java.io.FileInputStream;
import java.util.Hashtable;
import java.util.Properties;
import oracle.jbo.client.Configuration;
import oracle.jbo.common.ampool.EnvInfoProvider;
public class CustomEnvInfoProvider implements EnvInfoProvider {
public CustomEnvInfoProvider() {
super();
}
public Object getInfo(String infoType, Object env) {
if (EnvInfoProvider.INFO_TYPE_JDBC_PROPERTIES.equals(infoType)) {
Properties props = new Properties();
try {
props.load(new FileInputStream(System.getProperty("domain.name") +
"config.properties"));
} catch (Exception e) {
e.printStackTrace();
}
Object dsName = props.get(Configuration.JDBC_DS_NAME);
if (dsName != null) {
if (((Hashtable)env).containsKey(Configuration.JDBC_DS_NAME)) {
((Hashtable)env).put(Configuration.JDBC_DS_NAME,
(String)dsName);
}
}
}
return null;
}
public void modifyInitialContext(Object object) {
}
public int getNumOfRetries() {
return 0;
}
}
If we want AM to read the datasource string of our choice at runtime, we need to configure the AM property - " jbo.envinfoprovider". By default nothing is configured to it. we will need to implement our CustomEnvInfoProvider and configure it that property. Below is the snippet of the CustomEnvInfoProvider.
---------------------------------------------------------------------------------------------------
package model;
import java.io.FileInputStream;
import java.util.Hashtable;
import java.util.Properties;
import oracle.jbo.client.Configuration;
import oracle.jbo.common.ampool.EnvInfoProvider;
public class CustomEnvInfoProvider implements EnvInfoProvider {
public CustomEnvInfoProvider() {
super();
}
public Object getInfo(String infoType, Object env) {
if (EnvInfoProvider.INFO_TYPE_JDBC_PROPERTIES.equals(infoType)) {
Properties props = new Properties();
try {
props.load(new FileInputStream(System.getProperty("domain.name") +
"config.properties"));
} catch (Exception e) {
e.printStackTrace();
}
Object dsName = props.get(Configuration.JDBC_DS_NAME);
if (dsName != null) {
if (((Hashtable)env).containsKey(Configuration.JDBC_DS_NAME)) {
((Hashtable)env).put(Configuration.JDBC_DS_NAME,
(String)dsName);
}
}
}
return null;
}
public void modifyInitialContext(Object object) {
}
public int getNumOfRetries() {
return 0;
}
}
-------------------------------------------------------------------------------------------------
Now this CustomEnvInfoProvider is configured as shown below
Also ensure that the property - jbo. ampool.dynamicjdbccredentials is set true (It is true by default).
Now, when the application with this AM is run, the datasource string is read from config.properties file placed in the weblogic domain home directory. Even if the datasource string is changed in properties file dynamically ( as in while AM is running), the previous value is retained for a user session.
For further details about this concept refer the below link: