Class UniversalConnectionPoolExtension

java.lang.Object
io.helidon.integrations.cdi.configurable.AbstractConfigurableExtension<oracle.ucp.UniversalConnectionPool>
io.helidon.integrations.datasource.ucp.cdi.UniversalConnectionPoolExtension
All Implemented Interfaces:
Extension

public class UniversalConnectionPoolExtension extends AbstractConfigurableExtension<oracle.ucp.UniversalConnectionPool>
An AbstractConfigurableExtension that provides injection support for UniversalConnectionPoolManager and named UniversalConnectionPool instances.

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.

To support injection of the UniversalConnectionPoolManager, use normal CDI injection idioms:

// Inject the UniversalConnectionPoolManager into a private field named ucpManager:
@jakarta.inject.Inject
private oracle.ucp.admin.UniversalConnectionPoolManager ucpManager;

To support injection of a UniversalConnectionPool 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:

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

See the UCPBackedDataSourceExtension documentation for more information about how PoolDataSource instances are made eligible for injection from configuration such as this.

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

// Inject a UniversalConnectionPool whose getName() method returns test into a private field named ucp:
@jakarta.inject.Inject
@jakarta.inject.Named("test")
private oracle.ucp.UniversalConnectionPool ucp; // assert "test".equals(ucp.getName());

Note: Working directly with a UniversalConnectionPool is for advanced use cases only. Injecting and working with PoolDataSource instances is much more common, and PoolDataSource is the interface recommended by Oracle's documentation for users to interact with. See UCPBackedDataSourceExtension's documentation for more details.

See Also: