All Implemented Interfaces:
Extension

public class UCPBackedDataSourceExtension extends AbstractDataSourceExtension
An AbstractDataSourceExtension that arranges for named DataSource injection points to be satisfied by the Oracle Universal Connection Pool.

As with all portable extensions, to begin to make use of the features enabled by this class, ensure its containing artifact (normally a jar file) is on the runtime classpath of your CDI-enabled application.

In accordance with the CDI specification, instances of this class are not necessarily safe for concurrent use by multiple threads.

To support injection of a Universal Connection Pool-backed PoolDataSource named test, first ensure that enough MicroProfile Config configuration is present to create a valid PoolDataSource. For example, the following sample system properties are sufficient for a PoolDataSource named test to be created:

# (Note that "oracle.ucp.jdbc.PoolDataSource" below could be "javax.sql.DataSource" instead if you prefer
# that your configuration not refer directly to Oracle-specific classnames in its keys.)
oracle.ucp.jdbc.PoolDataSource.test.connectionFactoryClassName=oracle.jdbc.pool.OracleDataSource
oracle.ucp.jdbc.PoolDataSource.test.URL=jdbc:oracle:thin://@localhost:1521/XE
oracle.ucp.jdbc.PoolDataSource.test.user=scott
oracle.ucp.jdbc.PoolDataSource.test.password=tiger

With configuration such as the above, you can now inject the implicit PoolDataSource it defines:

// Inject a PoolDataSource qualified with the name test into a private javax.sql.DataSource-typed field named ds:
@jakarta.inject.Inject
@jakarta.inject.Named("test")
private javax.sql.DataSource ds;