Class AbstractDataSourceExtension
- All Implemented Interfaces:
Extension
- Direct Known Subclasses:
HikariCPBackedDataSourceExtension
,UCPBackedDataSourceExtension
Extension
whose subclasses arrange for DataSource
instances to be added as CDI beans.
Thread Safety
As with all CDI portable extensions, this class' instances are not safe for concurrent use by multiple threads.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
addBean
(BeanConfigurator<DataSource> beanConfigurator, Named name, Properties properties) Called to permit subclasses to add aDataSource
-typed bean using the suppliedBeanConfigurator
.protected final Config
Returns theConfig
instance used to acquire configuration property values.protected abstract String
getDataSourceName
(Matcher dataSourcePropertyPatternMatcher) Given aMatcher
that has been produced by thegetDataSourcePropertyPatternMatcher(String)
method, returns the relevant data source name.Returns aSet
of data source names known to thisAbstractDataSourceExtension
implementation.protected abstract String
getDataSourcePropertyName
(Matcher dataSourcePropertyPatternMatcher) Given aMatcher
that has been produced by thegetDataSourcePropertyPatternMatcher(String)
method, returns the relevant data source property name.protected abstract Matcher
getDataSourcePropertyPatternMatcher
(String configPropertyName) Returns aMatcher
for a property name.Returns aSet
of all known configuration property names.protected final void
Clears and then builds or rebuilds an internal map of data source properties whose contents will be processed eventually by theaddBean(BeanConfigurator, Named, Properties)
method.protected final Properties
putDataSourceProperties
(String dataSourceName, Properties properties) Adds additional synthesized properties to an internal map of data source properties whose contents will be processed eventually by theaddBean(BeanConfigurator, Named, Properties)
method.
-
Constructor Details
-
AbstractDataSourceExtension
protected AbstractDataSourceExtension()Creates a newAbstractDataSourceExtension
.
-
-
Method Details
-
getDataSourcePropertyPatternMatcher
Returns aMatcher
for a property name.Implementations of this method must not return
null
.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 thegetDataSourceName(Matcher)
andgetDataSourcePropertyName(Matcher)
methods.- 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
Given aMatcher
that has been produced by thegetDataSourcePropertyPatternMatcher(String)
method, returns the relevant data source name.Implementations of this method may return
null
.- Parameters:
dataSourcePropertyPatternMatcher
- aMatcher
produced by thegetDataSourcePropertyPatternMatcher(String)
method; must not benull
- Returns:
- a data source name, or
null
- See Also:
-
getDataSourcePropertyName
Given aMatcher
that has been produced by thegetDataSourcePropertyPatternMatcher(String)
method, returns the relevant data source property name.Implementations of this method may return
null
.- Parameters:
dataSourcePropertyPatternMatcher
- aMatcher
produced by thegetDataSourcePropertyPatternMatcher(String)
method; must not benull
- Returns:
- a data source property name, or
null
- See Also:
-
addBean
protected abstract void addBean(BeanConfigurator<DataSource> beanConfigurator, Named name, Properties properties) Called to permit subclasses to add aDataSource
-typed bean using the suppliedBeanConfigurator
.Implementations of this method will be called from an observer method that is observing the
AfterBeanDiscovery
container lifecycle event.- Parameters:
beanConfigurator
- theBeanConfigurator
to use to actually add a new bean; must not benull
name
- aNamed
instance qualifying theDataSource
-typed bean to be added; may benull
properties
- aProperties
instance containing properties relevant to the data source; must not benull
-
getConfig
Returns theConfig
instance used to acquire configuration property values.This method never returns
null
. -
getDataSourceNames
Returns aSet
of data source names known to thisAbstractDataSourceExtension
implementation.This method never returns
null
.The
Set
returned by this method is unmodifiable.- Returns:
- a non-
null
, unmodifiableSet
of known data source names
-
putDataSourceProperties
Adds additional synthesized properties to an internal map of data source properties whose contents will be processed eventually by theaddBean(BeanConfigurator, Named, Properties)
method.This method may return
null
.- Parameters:
dataSourceName
- the name of the data source under which the suppliedProperties
will be indexed; may benull
properties
- theProperties
to put; may benull
- Returns:
- the prior
Properties
indexed under the supplieddataSourceName
, ornull
-
initializeMasterProperties
protected final void initializeMasterProperties()Clears and then builds or rebuilds an internal map of data source properties whose contents will be processed eventually by theaddBean(BeanConfigurator, Named, Properties)
method.If no subclass explicitly calls this method, it will be called by the
addBean(BeanConfigurator, Named, Properties)
method just prior to its other activities.Once the
addBean(BeanConfigurator, Named, Properties)
method has run to completion, while this method may be called freely its use is discouraged and its effects will no longer be used. -
getPropertyNames
Returns aSet
of all known configuration property names.This method never returns
null
.The
Set
returned by this method is unmodifiable.The
Set
returned by this method is not safe for concurrent use by multiple threads.Any other semantics of the
Set
returned by this method are governed by the MicroProfile Config specification.- Returns:
- a non-
null
, unmodifiableSet
of all known configuration property names - See Also:
-