Class AlternativesManager


  • public class AlternativesManager
    extends Object
    This class has 2 responsibilities. 1.) to collect information about configured @Alternatives at boot time 2.) answer if a class is an enabled Alternative. This is needed for BeanManagerImpl.resolve(java.util.Set) The boot order for 1.) is to first register all the alternatives and stereotypes from the XML. After that the AnnotatedType scanning is performed and all @Alternatives with @Priority get added as well. We will also add classes which have an Alternative stereotype. After the AnnotatedTypes got scanned we have to fire the AfterTypeDiscovery event with the collected effective alternative classes sorted by their priority. Any extension can re-order the alternatives which then form the base of the resolve() handling at runtime.
    • Constructor Detail

      • AlternativesManager

        public AlternativesManager​(WebBeansContext webBeansContext)
    • Method Detail

      • addXmlStereoTypeAlternative

        public void addXmlStereoTypeAlternative​(Class<?> alternative)
        This methods gets called while scanning the various beans.xml files. It registers a <stereotype> alternative.
      • addXmlClazzAlternative

        public void addXmlClazzAlternative​(Class<?> alternative)
        This methods gets called while scanning the various beans.xml files. It registers a <class> alternative.
      • addPriorityClazzAlternative

        public void addPriorityClazzAlternative​(Class<?> clazz,
                                                jakarta.annotation.Priority priority)
        This method is used to add Alternatives which have a @Priority annotation. This is performed after the ProcessAnnotatedType events got fired.
      • addPrioritizedAlternativeBean

        public void addPrioritizedAlternativeBean​(jakarta.enterprise.inject.spi.Bean<?> prioritizedBean)
        This method is used to add Alternative Beans which implement the Prioritized interface This is performed after the Bean get's added.
      • getPrioritizedAlternatives

        public List<Class<?>> getPrioritizedAlternatives()
        Alternatives get ordered by their priority and as lowest priority all the alternatives added via XML get added.
        Returns:
        the list of sorted alternatives
      • isAlternative

        public boolean isAlternative​(jakarta.enterprise.inject.spi.Bean<?> bean)
        Returns:
        true if the given bean is a configured alternative
      • isAlternative

        public boolean isAlternative​(Class<?> beanType,
                                     Set<Class<? extends Annotation>> stereotypes)
        Returns:
        true if the given bean is a configured alternative
      • getXmlConfiguredAlternatives

        public Set<Class<?>> getXmlConfiguredAlternatives()
        Returns:
        all the alternative classes declared in beans.xml files
      • isAlternativeStereotype

        public boolean isAlternativeStereotype​(Class<? extends Annotation> stereo)
      • clear

        public void clear()