Class AbstractConfigurableExtension<T>
- Type Parameters:
T- the type for which thisAbstractConfigurableExtensionimplementation 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidaddBean(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 aSetof all known configuration property names.configPropertyValue(String configPropertyName) Given a configuration property name, returns anOptional<String>containing its value, or an emptyOptionalif no such configuration property value exists.protected final voidClears, and then builds or rebuilds, an internal set of properties whose contents will be processed eventually by theaddBean(BeanConfigurator, Named, Properties)method.protected abstract MatcherReturns aMatchergiven a configuration property name that can logically identify and provide access to at least its three component names.protected abstract StringGiven aMatcherthat has been produced by thematcher(String)method, returns the relevant name.names()Returns aSetof names known to thisAbstractConfigurableExtensionimplementation.protected abstract StringpropertyName(Matcher configPropertyNameMatcher) Given aMatcherthat has been produced by thematcher(String)method, returns the relevant property name, ornullif there is no such property name.protected final Propertiesput(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 aMatchergiven 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
Stringthat is a configuration property name, likecom.foo.Bar.name.propertyName, any implementation of this method must return a non-nullMatcherthat 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-
nullMatcher - Throws:
NullPointerException- ifconfigPropertyNameisnull- See Also:
-
name
Given aMatcherthat has been produced by thematcher(String)method, returns the relevant name.Implementations of this method may return
null.- Parameters:
configPropertyNameMatcher- aMatcherproduced by thematcher(String)method; must not benull- Returns:
- a name, or
null - Throws:
NullPointerException- ifconfigPropertyNameMatcherisnull- See Also:
-
propertyName
Given aMatcherthat has been produced by thematcher(String)method, returns the relevant property name, ornullif 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- aMatcherproduced by thematcher(String)method; must not benull- Returns:
- a property name, or
null - Throws:
NullPointerException- ifconfigPropertyNameMatcherisnull- 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
AfterBeanDiscoverycontainer lifecycle event.- Parameters:
beanConfigurator- theBeanConfiguratorto use to actually add a new bean; must not benullname- aNamedinstance qualifying theT-typed bean to be added; may benullproperties- aPropertiesinstance containing properties relevant to the object; must not benull- Throws:
NullPointerException- ifbeanConfiguratororpropertiesisnull- See Also:
-
configPropertyValue
Given a configuration property name, returns anOptional<String>containing its value, or an emptyOptionalif 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-
nullOptional - Throws:
NullPointerException- ifconfigPropertyNameisnull
-
names
Returns aSetof names known to thisAbstractConfigurableExtensionimplementation.This method never returns
null.The
Setreturned by this method is unmodifiable.- Returns:
- a non-
null, unmodifiableSetof 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 suppliedPropertieswill be indexed; may benullproperties- thePropertiesto put consisting of property names and their values; must not benull- Returns:
- the prior
Propertiesindexed under the suppliedname, ornull - Throws:
NullPointerException- ifpropertiesisnull
-
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 aSetof all known configuration property names.This method never returns
null.Overrides of this method must not return
null.The
Setreturned by this method is unmodifiable.Overrides of this method must ensure that the returned
Setis unmodifiable.The
Setreturned by this method is not safe for concurrent use by multiple threads.Overrides of this method may return
Setinstances that are not safe for concurrent use by multiple threads.The
Setreturned by this method and its overrides may be empty.The ordering of the elements contained by the
Setreturned by this method and its overrides is indeterminate.- Returns:
- a non-
null, unmodifiableSetof all known configuration property names
-