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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidaddBean(BeanConfigurator<DataSource> beanConfigurator, Named name, Properties properties) Called to permit subclasses to add aDataSource-typed bean using the suppliedBeanConfigurator.protected final ConfigReturns theConfiginstance used to acquire configuration property values.protected abstract StringgetDataSourceName(Matcher dataSourcePropertyPatternMatcher) Given aMatcherthat has been produced by thegetDataSourcePropertyPatternMatcher(String)method, returns the relevant data source name.Returns aSetof data source names known to thisAbstractDataSourceExtensionimplementation.protected abstract StringgetDataSourcePropertyName(Matcher dataSourcePropertyPatternMatcher) Given aMatcherthat has been produced by thegetDataSourcePropertyPatternMatcher(String)method, returns the relevant data source property name.protected abstract MatchergetDataSourcePropertyPatternMatcher(String configPropertyName) Returns aMatcherfor a property name.Returns aSetof all known configuration property names.protected final voidClears 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 PropertiesputDataSourceProperties(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 aMatcherfor a property name.Implementations of this method must not return
null.Given a
Stringlikejavax.sql.DataSource.dataSourceName.dataSourcePropertyName, any implementation of this method should return a non-nullMatcherthat 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-
nullMatcher - See Also:
-
getDataSourceName
Given aMatcherthat has been produced by thegetDataSourcePropertyPatternMatcher(String)method, returns the relevant data source name.Implementations of this method may return
null.- Parameters:
dataSourcePropertyPatternMatcher- aMatcherproduced by thegetDataSourcePropertyPatternMatcher(String)method; must not benull- Returns:
- a data source name, or
null - See Also:
-
getDataSourcePropertyName
Given aMatcherthat has been produced by thegetDataSourcePropertyPatternMatcher(String)method, returns the relevant data source property name.Implementations of this method may return
null.- Parameters:
dataSourcePropertyPatternMatcher- aMatcherproduced 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
AfterBeanDiscoverycontainer lifecycle event.- Parameters:
beanConfigurator- theBeanConfiguratorto use to actually add a new bean; must not benullname- aNamedinstance qualifying theDataSource-typed bean to be added; may benullproperties- aPropertiesinstance containing properties relevant to the data source; must not benull
-
getConfig
Returns theConfiginstance used to acquire configuration property values.This method never returns
null.- Returns:
- a non-
nullConfiginstance - See Also:
-
getDataSourceNames
Returns aSetof data source names known to thisAbstractDataSourceExtensionimplementation.This method never returns
null.The
Setreturned by this method is unmodifiable.- Returns:
- a non-
null, unmodifiableSetof 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 suppliedPropertieswill be indexed; may benullproperties- thePropertiesto put; may benull- Returns:
- the prior
Propertiesindexed 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.- See Also:
-
getPropertyNames
Returns aSetof all known configuration property names.This method never returns
null.The
Setreturned by this method is unmodifiable.The
Setreturned by this method is not safe for concurrent use by multiple threads.Any other semantics of the
Setreturned by this method are governed by the MicroProfile Config specification.- Returns:
- a non-
null, unmodifiableSetof all known configuration property names - See Also:
-