@@ -0,0 +1,2327 @@
+package org.saiku.plugin;%0A%0Aimport mondrian.spi.DataSourceResolver;%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;%0Aimport org.pentaho.platform.api.data.DBDatasourceServiceException;%0Aimport org.pentaho.platform.api.data.IDBDatasourceService;%0Aimport org.pentaho.platform.api.engine.ObjectFactoryException;%0Aimport org.pentaho.platform.engine.core.system.PentahoSessionHolder;%0Aimport org.pentaho.platform.engine.core.system.PentahoSystem;%0Aimport org.pentaho.platform.web.servlet.messages.Messages;%0Aimport javax.sql.DataSource;%0A%0A/**%0A * Created by bugg on 06/04/16.%0A */%0Apublic class PentahoDSResolver implements DataSourceResolver %7B%0A  private static final Log logger = LogFactory.getLog( PentahoDataSourceResolver.class );%0A%0A  public DataSource lookup( String dataSourceName ) throws Exception %7B%0A    javax.sql.DataSource datasource = null;%0A    String unboundDsName = null;%0A    IDBDatasourceService datasourceSvc = null;%0A    try %7B%0A      datasourceSvc =%0A          PentahoSystem.getObjectFactory().get( IDBDatasourceService.class, PentahoSessionHolder.getSession() );%0A      unboundDsName = datasourceSvc.getDSUnboundName( dataSourceName );%0A      datasource = datasourceSvc.getDataSource( unboundDsName );%0A    %7D catch ( ObjectFactoryException e ) %7B%0A      logger.error( Messages.getInstance().getErrorString( %22PentahoXmlaServlet.ERROR_0002_UNABLE_TO_INSTANTIATE%22 ), e ); //$NON-NLS-1$%0A      throw e;%0A    %7D catch ( DBDatasourceServiceException e ) %7B%0A      /* We tried to find the datasource using unbound name.%0A      ** Now as a fall back we will attempt to find this datasource as it is.%0A      ** For example jboss/datasource/Hibernate. The unbound name ends up to be Hibernate%0A      ** We will first look for Hibernate and if we fail then look for jboss/datasource/Hibernate */%0A%0A      logger.warn( Messages.getInstance().getString(%0A          %22PentahoXmlaServlet.WARN_0001_UNABLE_TO_FIND_UNBOUND_NAME%22, dataSourceName, unboundDsName ), e ); //$NON-NLS-1$%0A      try %7B%0A        datasource = datasourceSvc.getDataSource( dataSourceName );%0A      %7D catch ( DBDatasourceServiceException dbse ) %7B%0A        logger%0A            .error( Messages.getInstance().getErrorString( %22PentahoXmlaServlet.ERROR_0002_UNABLE_TO_INSTANTIATE%22 ), e ); //$NON-NLS-1$%0A        throw dbse;%0A      %7D%0A    %7D%0A    return datasource;%0A  %7D%0A%7D%0A

test DS resolver for Mondrian 4 OSGI