Class AbstractConfigurableExtension<T>

java.lang.Object
io.helidon.integrations.cdi.configurable.AbstractConfigurableExtension<T>
Type Parameters:
T - the type for which this AbstractConfigurableExtension implementation installs instances
All Implemented Interfaces:
Extension
Direct Known Subclasses:
AbstractDataSourceExtension, UniversalConnectionPoolExtension

public abstract class AbstractConfigurableExtension<T> extends Object implements Extension
A convenient, abstract 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:

  1. Type name: the class name of the kind of object this extension manages. Example: javax.sql.DataSource
  2. Name: a name designating one of potentially many such objects. Example: prod
  3. Property name: a name of a property of the kind of object this extension manages. Example: user
  4. 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 Details

  • Method Details

    • matcher

      protected abstract Matcher matcher(String configPropertyName)
      Returns a Matcher 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, like com.foo.Bar.name.propertyName, any implementation of this method must return a non-null Matcher that is capable of being supplied to the name(Matcher) and propertyName(Matcher) methods.

      Parameters:
      configPropertyName - a configuration property name that logically contains a type name, a name and a property name; must not be null
      Returns:
      a non-null Matcher
      Throws:
      NullPointerException - if configPropertyName is null
      See Also:
    • name

      protected abstract String name(Matcher configPropertyNameMatcher)
      Given a Matcher that has been produced by the matcher(String) method, returns the relevant name.

      Implementations of this method may return null.

      Parameters:
      configPropertyNameMatcher - a Matcher produced by the matcher(String) method; must not be null
      Returns:
      a name, or null
      Throws:
      NullPointerException - if configPropertyNameMatcher is null
      See Also:
    • propertyName

      protected abstract String propertyName(Matcher configPropertyNameMatcher)
      Given a Matcher that has been produced by the matcher(String) method, returns the relevant property name, or null 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 - a Matcher produced by the matcher(String) method; must not be null
      Returns:
      a property name, or null
      Throws:
      NullPointerException - if configPropertyNameMatcher is null
      See Also:
    • addBean

      protected abstract void addBean(BeanConfigurator<T> beanConfigurator, Named name, Properties properties)
      Called internally to permit subclasses to add a T-typed bean, qualified with at least the supplied Named, using the supplied BeanConfigurator.

      Implementations of this method will be called from an observer method that is observing the AfterBeanDiscovery container lifecycle event.

      Parameters:
      beanConfigurator - the BeanConfigurator to use to actually add a new bean; must not be null
      name - a Named instance qualifying the T-typed bean to be added; may be null
      properties - a Properties instance containing properties relevant to the object; must not be null
      Throws:
      NullPointerException - if beanConfigurator or properties is null
      See Also:
    • configPropertyValue

      protected Optional<String> configPropertyValue(String configPropertyName)
      Given a configuration property name, returns an Optional<String> containing its value, or an empty Optional 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 be null
      Returns:
      a non-null Optional
      Throws:
      NullPointerException - if configPropertyName is null
    • names

      protected final Set<String> names()
      Returns a Set of names known to this AbstractConfigurableExtension implementation.

      This method never returns null.

      The Set returned by this method is unmodifiable.

      Returns:
      a non-null, unmodifiable Set of known names
    • put

      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 the addBean(BeanConfigurator, Named, Properties) method.

      This method may return null.

      Parameters:
      name - the name of the object under which the supplied Properties will be indexed; may be null
      properties - the Properties to put consisting of property names and their values; must not be null
      Returns:
      the prior Properties indexed under the supplied name, or null
      Throws:
      NullPointerException - if properties is null
    • initializeNamedProperties

      protected final void initializeNamedProperties()
      Clears, and then builds or rebuilds, an internal set of properties whose contents will be processed eventually by the addBean(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

      protected Set<String> configPropertyNames()
      Returns a Set 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, unmodifiable Set of all known configuration property names