Class CdiHelper
java.lang.Object
fr.paris.lutece.portal.service.util.CdiHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TObtains a contextual reference for a certain bean type of the bean.static <T> TgetReference(Type beanType, String name) Obtains a contextual reference for a certain EL name and a certain bean type of the bean.static <T> TGeneric service resolution using CDI Instance<T>.
-
Constructor Details
-
CdiHelper
public CdiHelper()
-
-
Method Details
-
getReference
Obtains a contextual reference for a certain EL name and a certain bean type of the bean.
- Parameters:
beanType- a bean type that must be implemented by any client proxy that is returnedname- the EL name- Returns:
- a contextual reference
- Throws:
IllegalArgumentException- if the given type is not a bean type of the given beanIllegalStateException- if called during application initialization, before theAfterDeploymentValidationevent is fired.
-
getBean
Obtains a contextual reference for a certain bean type of the bean.
- Parameters:
clazz- the class of the bean- Returns:
- a contextual reference
-
resolve
Generic service resolution using CDI Instance<T>. Provides proper error handling and logging for missing services.- Type Parameters:
T- Service type- Parameters:
instance- CDI Instance containerserviceName- Name/qualifier of the service to resolve- Returns:
- resolved service instance
- Throws:
IllegalStateException- if service cannot be resolved
-