Class UCPBackedDataSourceExtension
- All Implemented Interfaces:
Extension
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;
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final void
addBean
(BeanConfigurator<DataSource> beanConfigurator, Named dataSourceName, Properties dataSourceProperties) Called internally to permit subclasses to add aT
-typed bean, qualified with at least the suppliedNamed
, using the suppliedBeanConfigurator
.protected final String
getDataSourceName
(Matcher dataSourcePropertyPatternMatcher) Given aMatcher
that has been produced by theAbstractDataSourceExtension.getDataSourcePropertyPatternMatcher(String)
method, returns the relevant data source name.protected final String
getDataSourcePropertyName
(Matcher dataSourcePropertyPatternMatcher) Given aMatcher
that has been produced by theAbstractDataSourceExtension.getDataSourcePropertyPatternMatcher(String)
method, returns the relevant data source property name.protected final Matcher
getDataSourcePropertyPatternMatcher
(String configPropertyName) Returns aMatcher
for a property name.Methods inherited from class io.helidon.integrations.datasource.cdi.AbstractDataSourceExtension
getConfig, getDataSourceNames, getPropertyNames, initializeMasterProperties, matcher, name, propertyName, putDataSourceProperties
Methods inherited from class io.helidon.integrations.cdi.configurable.AbstractConfigurableExtension
configPropertyNames, configPropertyValue, initializeNamedProperties, names, put
-
Constructor Details
-
UCPBackedDataSourceExtension
Deprecated.For use by CDI only.Creates a newUCPBackedDataSourceExtension
.
-
-
Method Details
-
getDataSourcePropertyPatternMatcher
Description copied from class:AbstractDataSourceExtension
Returns aMatcher
for a property name.Implementations of this method must not return
null
.Implementations of this method must not invoke the
AbstractDataSourceExtension.matcher(String)
method or an infinite loop may result.Given a
String
likejavax.sql.DataSource.dataSourceName.dataSourcePropertyName
, any implementation of this method should return a non-null
Matcher
that is capable of being supplied to theAbstractDataSourceExtension.getDataSourceName(Matcher)
andAbstractDataSourceExtension.getDataSourcePropertyName(Matcher)
methods.- Specified by:
getDataSourcePropertyPatternMatcher
in classAbstractDataSourceExtension
- Parameters:
configPropertyName
- the name of a configuration property that logically contains a data source name and a data source property name; must not benull
- Returns:
- a non-
null
Matcher
- See Also:
-
getDataSourceName
Description copied from class:AbstractDataSourceExtension
Given aMatcher
that has been produced by theAbstractDataSourceExtension.getDataSourcePropertyPatternMatcher(String)
method, returns the relevant data source name.Implementations of this method may return
null
.Implementations of this method must not invoke the
AbstractDataSourceExtension.name(Matcher)
method or an infinite loop may result.- Specified by:
getDataSourceName
in classAbstractDataSourceExtension
- Parameters:
dataSourcePropertyPatternMatcher
- aMatcher
produced by theAbstractDataSourceExtension.getDataSourcePropertyPatternMatcher(String)
method; must not benull
- Returns:
- a data source name, or
null
- See Also:
-
getDataSourcePropertyName
Description copied from class:AbstractDataSourceExtension
Given aMatcher
that has been produced by theAbstractDataSourceExtension.getDataSourcePropertyPatternMatcher(String)
method, returns the relevant data source property name.Implementations of this method may return
null
.Implementations of this method must not invoke the
AbstractDataSourceExtension.propertyName(Matcher)
method or an infinite loop may result.- Specified by:
getDataSourcePropertyName
in classAbstractDataSourceExtension
- Parameters:
dataSourcePropertyPatternMatcher
- aMatcher
produced by theAbstractDataSourceExtension.getDataSourcePropertyPatternMatcher(String)
method; must not benull
- Returns:
- a data source property name, or
null
- See Also:
-
addBean
protected final void addBean(BeanConfigurator<DataSource> beanConfigurator, Named dataSourceName, Properties dataSourceProperties) Description copied from class:AbstractConfigurableExtension
Called internally to permit subclasses to add aT
-typed bean, qualified with at least the suppliedNamed
, using the suppliedBeanConfigurator
.Implementations of this method will be called from an observer method that is observing the
AfterBeanDiscovery
container lifecycle event.- Specified by:
addBean
in classAbstractConfigurableExtension<DataSource>
- Parameters:
beanConfigurator
- theBeanConfigurator
to use to actually add a new bean; must not benull
dataSourceName
- aNamed
instance qualifying theT
-typed bean to be added; may benull
dataSourceProperties
- aProperties
instance containing properties relevant to the object; must not benull
- See Also:
-