Class FHIRDbTestConnectionStrategy
- java.lang.Object
-
- com.ibm.fhir.persistence.jdbc.connection.FHIRDbTestConnectionStrategy
-
- All Implemented Interfaces:
FHIRDbConnectionStrategy
public class FHIRDbTestConnectionStrategy extends Object implements FHIRDbConnectionStrategy
Hides the logic behind obtaining a JDBCConnection
from the DAO code. This strategy object is local to a thread, and because we use the same underlying connection to our test database within a transaction, we only need to configure the connection once. We can track this initialization with nothing more complicated than a Boolean flag. Use by unit tests or other scenarios where connections are obtained using an IConnectionProvider implementation, outside the scope of a JEE container. For example, this is used when connecting to in-memory instances of Derby when running persistence layer unit-tests.
-
-
Constructor Summary
Constructors Constructor Description FHIRDbTestConnectionStrategy(IConnectionProvider cp, Action action)
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 capabilitiesQueryHints
getQueryHints()
Append the given hint to FHIR search queries
-
-
-
Constructor Detail
-
FHIRDbTestConnectionStrategy
public FHIRDbTestConnectionStrategy(IConnectionProvider cp, Action action)
Public constructor- Parameters:
cp
-action
-
-
-
Method Detail
-
getConnection
public Connection getConnection() throws FHIRPersistenceDBConnectException
Description copied from interface:FHIRDbConnectionStrategy
Get a connection to the desired data source identified by the currentFHIRRequestContext
- Specified by:
getConnection
in interfaceFHIRDbConnectionStrategy
- 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
- Returns:
- the datastore/source flavor from the FHIR configuration
- Throws:
FHIRPersistenceDataAccessException
- if there is an issue with the configuration
-
getQueryHints
public QueryHints getQueryHints()
Description copied from interface:FHIRDbConnectionStrategy
Append the given hint to FHIR search queries- Specified by:
getQueryHints
in interfaceFHIRDbConnectionStrategy
- Returns:
-
-