Package org.silverpeas.core.util
Interface BeanContainer
-
- All Known Implementing Classes:
CDIContainer
,TestBeanContainer
public interface BeanContainer
I represents the strategy used to manage the life-cycle of the objects (aka the beans) in Silverpeas. Usually, the implementation of this interface is a wrapper or an adaptor to an existing IoD container (Injection Of Dependency container) such as CDI or Spring. All implementation of a bean management container must implement this interface.- Author:
- mmoquillon
-
-
Method Summary
All Methods Instance Methods Abstract 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
<T> T getBeanByName(String name) throws IllegalStateException
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.- 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
<T> T getBeanByType(Class<T> type, Annotation... qualifiers) throws IllegalStateException
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.- 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
<T> Set<T> getAllBeansByType(Class<T> type, Annotation... qualifiers)
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.- 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.
-
-