Class FHIRDbTenantDatasourceConnectionStrategy
- java.lang.Object
-
- org.linuxforhealth.fhir.persistence.jdbc.connection.FHIRDbConnectionStrategyBase
-
- org.linuxforhealth.fhir.persistence.jdbc.connection.FHIRDbTenantDatasourceConnectionStrategy
-
- All Implemented Interfaces:
FHIRDbConnectionStrategy
,QueryHints
public class FHIRDbTenantDatasourceConnectionStrategy extends FHIRDbConnectionStrategyBase
Hides the logic behind obtaining a JDBCConnection
from the DAO code. Uses datasource and tenant ids configured in the fhir-server-config to map directly to a managed datasource. All managed datasources must be available when the server starts. This differs from the proxy datasource strategyFHIRDbPropsConnectionStrategy
which supports dynamic (programmatic) definition of managed datasources.
-
-
Constructor Summary
Constructors Constructor Description FHIRDbTenantDatasourceConnectionStrategy(javax.transaction.TransactionSynchronizationRegistry trxSyncRegistry, Action newConnectionAction, boolean enableReadOnlyReplicas)
Public constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.sql.Connection
getConnection()
Get a connection to the desired data source identified by the currentFHIRRequestContext
FHIRDbFlavor
getFlavor()
Get the flavor of the database we are working with to reveal its capabilitiesstatic java.lang.String
makeTenantDatasourceJNDIName(java.lang.String jndiBase, java.lang.String tenantId, java.lang.String dsId, boolean readOnly)
-
Methods inherited from class org.linuxforhealth.fhir.persistence.jdbc.connection.FHIRDbConnectionStrategyBase
applySearchOptimizerOptions, configure, getConnection, getHintValue, getQueryHints
-
-
-
-
Constructor Detail
-
FHIRDbTenantDatasourceConnectionStrategy
public FHIRDbTenantDatasourceConnectionStrategy(javax.transaction.TransactionSynchronizationRegistry trxSyncRegistry, Action newConnectionAction, boolean enableReadOnlyReplicas) throws FHIRException
Public constructor. The proxy datasource must be present (registered in JNDI) at server startup.- Throws:
FHIRPersistenceDBConnectException
- if the proxy datasource is not configuredFHIRException
-
-
Method Detail
-
makeTenantDatasourceJNDIName
public static java.lang.String makeTenantDatasourceJNDIName(java.lang.String jndiBase, java.lang.String tenantId, java.lang.String dsId, boolean readOnly)
-
getConnection
public java.sql.Connection getConnection() throws FHIRPersistenceDBConnectException
Description copied from interface:FHIRDbConnectionStrategy
Get a connection to the desired data source identified by the currentFHIRRequestContext
- Returns:
- a
Connection
. Never null. - Throws:
FHIRPersistenceDBConnectException
-
getFlavor
public FHIRDbFlavor getFlavor() throws FHIRPersistenceDataAccessException
Description copied from interface:FHIRDbConnectionStrategy
Get the flavor of the database we are working with to reveal its capabilities- Specified by:
getFlavor
in interfaceFHIRDbConnectionStrategy
- Overrides:
getFlavor
in classFHIRDbConnectionStrategyBase
- Returns:
- the datastore/source flavor from the FHIR configuration
- Throws:
FHIRPersistenceDataAccessException
- if there is an issue with the configuration
-
-