return ds;
}
}
public DataSource getDataSource2(StoreContext ctx) {
Log log = getLog(LOG_RUNTIME);
DataSource ds = null;
// Try to obtain from the StoreContext first.
if (ctx != null && StringUtils.isNotEmpty(ctx.getConnectionFactory2Name())) {
ds = (DataSource) ctx.getConnectionFactory2();
if (ds == null) {
// fail fast. If the non-jta-data-source is configured on the context we want an immediate error.
throw new UserException(_loc.get("invalid-datasource", ctx.getConnectionFactory2Name())).setFatal(true);
}
if(! (ds instanceof DecoratingDataSource)) {
ds = DataSourceFactory.decorateDataSource(ds, this, false);
}
if (log.isTraceEnabled()) {
log.trace("Found datasource2: " + ds + " from StoreContext using jndiName: "
+ ctx.getConnectionFactory2Name());
}
return ds;
}
// If not set on context or value from context is not available try cf2 from config
else{
ds = (DataSource) getConnectionFactory2();
if (log.isTraceEnabled()) {
log.trace("Found datasource 2: "+ ds + " from config. StoreContext: " + ctx);
}
}
// fallback to cf1 / datasource1
if (ds == null) {
if(log.isTraceEnabled()) {
log.trace("Trying datasource1");
}
return getDataSource(ctx);
}
// prefer the global connection 2 auth info if given