Class AbstractDataSourceExtension
- java.lang.Object
-
- io.helidon.integrations.datasource.cdi.AbstractDataSourceExtension
-
- All Implemented Interfaces:
Extension
- Direct Known Subclasses:
HikariCPBackedDataSourceExtension
,UCPBackedDataSourceExtension
public abstract class AbstractDataSourceExtension extends Object implements Extension
An abstractExtension
whose subclasses arrange forDataSource
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
Constructors Modifier Constructor Description protected
AbstractDataSourceExtension()
Creates a newAbstractDataSourceExtension
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
addBean(BeanConfigurator<DataSource> beanConfigurator, Named name, Properties properties)
Called to permit subclasses to add aDataSource
-typed bean using the suppliedBeanConfigurator
.protected Config
getConfig()
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.protected Set<String>
getDataSourceNames()
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.protected Set<String>
getPropertyNames()
Returns aSet
of all known configuration property names.protected 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.protected 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 Detail
-
AbstractDataSourceExtension
protected AbstractDataSourceExtension()
Creates a newAbstractDataSourceExtension
.
-
-
Method Detail
-
getDataSourcePropertyPatternMatcher
protected abstract Matcher getDataSourcePropertyPatternMatcher(String configPropertyName)
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(Matcher)
,getDataSourcePropertyName(Matcher)
-
getDataSourceName
protected abstract String getDataSourceName(Matcher dataSourcePropertyPatternMatcher)
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:
getDataSourcePropertyPatternMatcher(String)
-
getDataSourcePropertyName
protected abstract String getDataSourcePropertyName(Matcher dataSourcePropertyPatternMatcher)
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:
getDataSourcePropertyPatternMatcher(String)
-
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
protected final Config getConfig()
Returns theConfig
instance used to acquire configuration property values.This method never returns
null
.
-
getDataSourceNames
protected final Set<String> 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
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.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
protected final Set<String> 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:
Config.getConfigSources()
,ConfigSource.getPropertyNames()
-
-