Class CDIContainer

  • All Implemented Interfaces:
    BeanContainer

    public class CDIContainer
    extends Object
    implements BeanContainer
    Implementation of the bean container above the CDI framework. This implementation can be found either by the Service Loader API of Java or by CDI itself. The later must be avoided and should be used only in the Silverpeas Core API implementation for only some peculiar reasons.
    Author:
    mmoquillon
    • Constructor Detail

      • CDIContainer

        public CDIContainer()
    • Method Detail

      • getBeanByName

        public <T> T getBeanByName​(String name)
                            throws IllegalStateException
        Description copied from interface: BeanContainer
        Gets a bean managed in this container by its name. If no such bean exists in the bean container, then an IllegalStateException exception is thrown.
        Specified by:
        getBeanByName in interface BeanContainer
        Type Parameters:
        T - the type of the bean to return.
        Parameters:
        name - the name of the bean.
        Returns:
        the bean matching the specified name.
        Throws:
        IllegalStateException - if no bean can be found with the specified name.
      • getBeanByType

        public <T> T getBeanByType​(Class<T> type,
                                   Annotation... qualifiers)
                            throws IllegalStateException
        Description copied from interface: BeanContainer
        Gets a bean managed in this container by its type and optionally by some qualifiers. If no such bean exists in the bean container, then an IllegalStateException exception is thrown.
        Specified by:
        getBeanByType in interface BeanContainer
        Type Parameters:
        T - the type of the bean to return.
        Parameters:
        type - the type of the bean.
        qualifiers - zero, one or more qualifiers annotating the bean to look for.
        Returns:
        the bean satisfying the expected type and, if any, the expected qualifiers.
        Throws:
        IllegalStateException - if no bean of the specified type and with the specified qualifiers can be found.
      • getAllBeansByType

        public <T> Set<T> getAllBeansByType​(Class<T> type,
                                            Annotation... qualifiers)
        Description copied from interface: BeanContainer
        Gets a bean managed in this container by its name. If no such bean exists in the bean container, then an empty set is returned.
        Specified by:
        getAllBeansByType in interface BeanContainer
        Type Parameters:
        T - the type of the bean to return.
        Parameters:
        type - the type of the bean.
        qualifiers - zero, one or more qualifiers annotating the bean to look for.
        Returns:
        a set of beans satisfying the expected type and, if any, the expected qualifiers, or an empty set otherwise.