use of org.apache.synapse.commons.datasource.RepositoryBasedDataSourceFinder in project wso2-synapse by wso2.
the class JDBCConfiguration method lookupDataSource.
/**
* Lookup the DataSource on JNDI using the specified name and optional properties
*
* @return a DataSource looked up using the specified JNDI properties
*/
private DataSource lookupDataSource() {
DataSource dataSource = null;
RepositoryBasedDataSourceFinder finder = DataSourceRepositoryHolder.getInstance().getRepositoryBasedDataSourceFinder();
if (finder.isInitialized()) {
// First try a lookup based on the data source name only
dataSource = finder.find(dataSourceName);
}
if (dataSource == null) {
// Decrypt the password if needed
String password = jndiProperties.getProperty(Context.SECURITY_CREDENTIALS);
if (password != null && !"".equals(password)) {
jndiProperties.put(Context.SECURITY_CREDENTIALS, getActualPassword(password));
}
// Lookup the data source using the specified jndi properties
dataSource = DataSourceFinder.find(dataSourceName, jndiProperties);
if (dataSource == null) {
handleException("Cannot find a DataSource " + dataSourceName + " for given JNDI" + " properties :" + jndiProperties);
}
}
if (dataSource != null) {
log.info("Successfully looked up datasource " + dataSourceName);
}
return dataSource;
}
use of org.apache.synapse.commons.datasource.RepositoryBasedDataSourceFinder in project wso2-synapse by wso2.
the class AbstractDBMediator method lookupDataSource.
/**
* Lookup the DataSource on JNDI using the specified name and optional properties
*
* @param dataSourceName the name of the data source to lookup
* @param jndiProperties the JNDI properties identifying a data source provider
* @return a DataSource looked up using the specified JNDI properties
*/
private DataSource lookupDataSource(String dataSourceName, Properties jndiProperties) {
DataSource dataSource = null;
RepositoryBasedDataSourceFinder finder = DataSourceRepositoryHolder.getInstance().getRepositoryBasedDataSourceFinder();
if (finder.isInitialized()) {
// first try a lookup based on the data source name only
dataSource = finder.find(dataSourceName);
}
if (dataSource == null) {
// decrypt the password if needed
String password = jndiProperties.getProperty(Context.SECURITY_CREDENTIALS);
if (password != null && !"".equals(password)) {
jndiProperties.put(Context.SECURITY_CREDENTIALS, getActualPassword(password));
}
// lookup the data source using the specified jndi properties
dataSource = DataSourceFinder.find(dataSourceName, jndiProperties);
}
if (dataSource != null) {
MBeanRepository mBeanRepository = DatasourceMBeanRepository.getInstance();
Object mBean = mBeanRepository.getMBean(dataSourceName);
if (mBean instanceof DBPoolView) {
setDbPoolView((DBPoolView) mBean);
}
log.info("Successfully looked up datasource " + dataSourceName + ".");
}
return dataSource;
}
Aggregations