org.pentaho.platform.engine.services.connection.datasource.dbcp.tenantaware
Class AbstractTenantAwareDatasourceService

java.lang.Object
  extended by org.pentaho.platform.engine.services.connection.datasource.dbcp.BaseDatasourceService
      extended by org.pentaho.platform.engine.services.connection.datasource.dbcp.PooledOrJndiDatasourceService
          extended by org.pentaho.platform.engine.services.connection.datasource.dbcp.tenantaware.AbstractTenantAwareDatasourceService
All Implemented Interfaces:
IDatasourceService, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
TenantAwareLoginParsingDatasourceService, TenantAwareSessionVariableDatasourceService

public abstract class AbstractTenantAwareDatasourceService
extends PooledOrJndiDatasourceService
implements org.springframework.beans.factory.InitializingBean

This class provides the foundation for combining a users' tenant ID with the datasource name being requested at runtime. The concept is this - - - a- Build against a datasource like "Customers" or "Products" b- At runtime, the users' tenant ID is substituted in a pattern to retrieve the Datasource with the Tenant ID For example: User=Joe, Tenant=ABC_COMPANY Requested Datasource: Customers Actual Returned Datasource: ABC_COMPANY-Datasource When Joe runs a report that uses the datasource Customers, subclassers will use the tenant-ID and the datasource name to fulfill the request -

Author:
mbatchelor

Field Summary
 
Fields inherited from interface org.pentaho.platform.api.data.IDatasourceService
IDATASOURCE_SERVICE, JDBC_DATASOURCE, JDBC_POOL
 
Constructor Summary
AbstractTenantAwareDatasourceService()
           
 
Method Summary
 void afterPropertiesSet()
           
 DataSource getDataSource(String dsName)
          Since JNDI is supported different ways in different app servers, it's nearly impossible to have a ubiquitous way to look up a datasource.
 String getDatasourceNameFormat()
           
abstract  String getTenantId()
          This abstract method must be implemented by subclasses - this should return a string containing the tenant's ID.
 boolean isRequireTenantId()
           
 void setDatasourceNameFormat(String value)
          Getters and Setters
 void setRequireTenantId(boolean value)
           
 
Methods inherited from class org.pentaho.platform.engine.services.connection.datasource.dbcp.PooledOrJndiDatasourceService
clearCache, clearDataSource
 
Methods inherited from class org.pentaho.platform.engine.services.connection.datasource.dbcp.BaseDatasourceService
getDSBoundName, getDSUnboundName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTenantAwareDatasourceService

public AbstractTenantAwareDatasourceService()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception

getDataSource

public DataSource getDataSource(String dsName)
                         throws DatasourceServiceException
Description copied from class: PooledOrJndiDatasourceService
Since JNDI is supported different ways in different app servers, it's nearly impossible to have a ubiquitous way to look up a datasource. This method is intended to hide all the lookups that may be required to find a jndi name.

Specified by:
getDataSource in interface IDatasourceService
Overrides:
getDataSource in class PooledOrJndiDatasourceService
Parameters:
dsName - The Datasource name
Returns:
DataSource if there is one bound in JNDI
Throws:
DatasourceServiceException

getTenantId

public abstract String getTenantId()
This abstract method must be implemented by subclasses - this should return a string containing the tenant's ID.

Returns:
String ID of the Tenant

setDatasourceNameFormat

public void setDatasourceNameFormat(String value)
Getters and Setters


getDatasourceNameFormat

public String getDatasourceNameFormat()

setRequireTenantId

public void setRequireTenantId(boolean value)

isRequireTenantId

public boolean isRequireTenantId()