import org.pentaho.platform.engine.core.system.PentahoSystem;
public class PentahoDataSourceResolver implements DataSourceResolver {
Logger logger = Logger.getLogger(PentahoDataSourceResolver.class);
public DataSource lookup(String dataSourceName) throws Exception {
IDatasourceService datasourceSvc =
PentahoSystem.getObjectFactory().get(
IDatasourceService.class,
PentahoSessionHolder.getSession());
javax.sql.DataSource datasource;
try {
datasource =
datasourceSvc.getDataSource(
datasourceSvc.getDSUnboundName(dataSourceName));
}
catch (DatasourceServiceException e) {
Context initContext = new InitialContext();
if (dataSourceName != null && !dataSourceName.startsWith("java:/comp/env/")) {
dataSourceName = "java:/comp/env/" + dataSourceName;