Package org.silverpeas.core.util
Class CDIContainer
- java.lang.Object
-
- org.silverpeas.core.util.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 Summary
Constructors Constructor Description CDIContainer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Set<T>
getAllBeansByType(Class<T> type, Annotation... qualifiers)
Gets a bean managed in this container by its name.<T> T
getBeanByName(String name)
Gets a bean managed in this container by its name.<T> T
getBeanByType(Class<T> type, Annotation... qualifiers)
Gets a bean managed in this container by its type and optionally by some qualifiers.
-
-
-
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 interfaceBeanContainer
- 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 interfaceBeanContainer
- 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 interfaceBeanContainer
- 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.
-
-