Class AbstractConfigurableExtension<T>
- Type Parameters:
T
- the type for which thisAbstractConfigurableExtension
implementation installs instances
- All Implemented Interfaces:
Extension
- Direct Known Subclasses:
AbstractDataSourceExtension
,UniversalConnectionPoolExtension
Extension
whose subclasses arrange for instances of a particular type to be configured
and added as CDI beans.
There are four kinds of names defined by this extension:
- Type name: the class name of the kind of object this extension manages. Example:
javax.sql.DataSource
- Name: a name designating one of potentially many such objects. Example:
prod
- Property name: a name of a property of the kind of object this extension manages. Example:
user
- Configuration property name: a name of a configuration property that logically contains at least
the other three kinds of names. Example:
javax.sql.DataSource.prod.user
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<T> beanConfigurator, Named name, Properties properties) Called internally to permit subclasses to add aT
-typed bean, qualified with at least the suppliedNamed
, using the suppliedBeanConfigurator
.Returns aSet
of all known configuration property names.configPropertyValue
(String configPropertyName) Given a configuration property name, returns anOptional<String>
containing its value, or an emptyOptional
if no such configuration property value exists.protected final void
Clears, and then builds or rebuilds, an internal set of properties whose contents will be processed eventually by theaddBean(BeanConfigurator, Named, Properties)
method.protected abstract Matcher
Returns aMatcher
given a configuration property name that can logically identify and provide access to at least its three component names.protected abstract String
Given aMatcher
that has been produced by thematcher(String)
method, returns the relevant name.names()
Returns aSet
of names known to thisAbstractConfigurableExtension
implementation.protected abstract String
propertyName
(Matcher configPropertyNameMatcher) Given aMatcher
that has been produced by thematcher(String)
method, returns the relevant property name, ornull
if there is no such property name.protected final Properties
put
(String name, Properties properties) Adds additional synthesized properties (property names and their values) to an internal map of such properties whose contents will be processed eventually by theaddBean(BeanConfigurator, Named, Properties)
method.
-
Constructor Details
-
AbstractConfigurableExtension
protected AbstractConfigurableExtension()Creates a newAbstractConfigurableExtension
.
-
-
Method Details
-
matcher
Returns aMatcher
given a configuration property name that can logically identify and provide access to at least its three component names.Implementations of this method must not return
null
.Given a
String
that is a configuration property name, likecom.foo.Bar.name.propertyName
, any implementation of this method must return a non-null
Matcher
that is capable of being supplied to thename(Matcher)
andpropertyName(Matcher)
methods.- Parameters:
configPropertyName
- a configuration property name that logically contains a type name, a name and a property name; must not benull
- Returns:
- a non-
null
Matcher
- Throws:
NullPointerException
- ifconfigPropertyName
isnull
- See Also:
-
name
Given aMatcher
that has been produced by thematcher(String)
method, returns the relevant name.Implementations of this method may return
null
.- Parameters:
configPropertyNameMatcher
- aMatcher
produced by thematcher(String)
method; must not benull
- Returns:
- a name, or
null
- Throws:
NullPointerException
- ifconfigPropertyNameMatcher
isnull
- See Also:
-
propertyName
Given aMatcher
that has been produced by thematcher(String)
method, returns the relevant property name, ornull
if there is no such property name.Most implementations of this method will use the
Matcher.group(int)
method to produce the required property name.Implementations of this method may return
null
.- Parameters:
configPropertyNameMatcher
- aMatcher
produced by thematcher(String)
method; must not benull
- Returns:
- a property name, or
null
- Throws:
NullPointerException
- ifconfigPropertyNameMatcher
isnull
- See Also:
-
addBean
protected abstract void addBean(BeanConfigurator<T> beanConfigurator, Named name, Properties properties) 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.- Parameters:
beanConfigurator
- theBeanConfigurator
to use to actually add a new bean; must not benull
name
- aNamed
instance qualifying theT
-typed bean to be added; may benull
properties
- aProperties
instance containing properties relevant to the object; must not benull
- Throws:
NullPointerException
- ifbeanConfigurator
orproperties
isnull
- See Also:
-
configPropertyValue
Given a configuration property name, returns anOptional<String>
containing its value, or an emptyOptional
if no such configuration property value exists.This method never returns
null
.Overrides of this method must not return
null
.- Parameters:
configPropertyName
- a configuration property name; must not benull
- Returns:
- a non-
null
Optional
- Throws:
NullPointerException
- ifconfigPropertyName
isnull
-
names
Returns aSet
of names known to thisAbstractConfigurableExtension
implementation.This method never returns
null
.The
Set
returned by this method is unmodifiable.- Returns:
- a non-
null
, unmodifiableSet
of known names
-
put
Adds additional synthesized properties (property names and their values) to an internal map of such properties whose contents will be processed eventually by theaddBean(BeanConfigurator, Named, Properties)
method.This method may return
null
.- Parameters:
name
- the name of the object under which the suppliedProperties
will be indexed; may benull
properties
- theProperties
to put consisting of property names and their values; must not benull
- Returns:
- the prior
Properties
indexed under the suppliedname
, ornull
- Throws:
NullPointerException
- ifproperties
isnull
-
initializeNamedProperties
protected final void initializeNamedProperties()Clears, and then builds or rebuilds, an internal set of properties whose contents will be processed eventually by theaddBean(BeanConfigurator, Named, Properties)
method.If no subclass explicitly calls this method, as is common, 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:
-
configPropertyNames
Returns aSet
of all known configuration property names.This method never returns
null
.Overrides of this method must not return
null
.The
Set
returned by this method is unmodifiable.Overrides of this method must ensure that the returned
Set
is unmodifiable.The
Set
returned by this method is not safe for concurrent use by multiple threads.Overrides of this method may return
Set
instances that are not safe for concurrent use by multiple threads.The
Set
returned by this method and its overrides may be empty.The ordering of the elements contained by the
Set
returned by this method and its overrides is indeterminate.- Returns:
- a non-
null
, unmodifiableSet
of all known configuration property names
-