org.pentaho.platform.engine.services.connection.datasource.dbcp.tenantaware
Class AbstractTenantAwareDatasourceService
java.lang.Object
org.pentaho.platform.engine.services.connection.datasource.dbcp.BaseDatasourceService
org.pentaho.platform.engine.services.connection.datasource.dbcp.PooledOrJndiDatasourceService
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
AbstractTenantAwareDatasourceService
public AbstractTenantAwareDatasourceService()
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()