Package com.sun.faces.cdi
Class CdiUtils
java.lang.Object
com.sun.faces.cdi.CdiUtils
public final class CdiUtils extends Object
A static utility class for CDI.
-
Method Summary
Modifier and Type Method Description static void
addAnnotatedTypes(jakarta.enterprise.inject.spi.BeforeBeanDiscovery beforeBean, jakarta.enterprise.inject.spi.BeanManager beanManager, Class<?>... types)
static Behavior
createBehavior(jakarta.enterprise.inject.spi.BeanManager beanManager, String value)
Create a behavior using the FacesBehavior value attribute.static Converter<?>
createConverter(jakarta.enterprise.inject.spi.BeanManager beanManager, Class<?> forClass)
Create a converter using the FacesConverter forClass attribute.static Converter<?>
createConverter(jakarta.enterprise.inject.spi.BeanManager beanManager, String value)
Create a converter using the FacesConverter value attribute.static DataModel<?>
createDataModel(Class<?> forClass)
static Validator<?>
createValidator(jakarta.enterprise.inject.spi.BeanManager beanManager, String value)
Create a validator using the FacesValidator value attribute.static <A extends Annotation>
Optional<A>getAnnotation(jakarta.enterprise.inject.spi.BeanManager beanManager, jakarta.enterprise.inject.spi.Annotated annotated, Class<A> annotationType)
Finds an annotation in an Annotated, taking stereo types into accountstatic <T> T
getBeanInstance(Class<T> type, boolean create)
Returns concrete (non-proxied) bean instance of given class in current context.static <T> T
getBeanReference(jakarta.enterprise.inject.spi.BeanManager beanManager, Class<T> type, Annotation... qualifiers)
static <T> T
getBeanReference(Class<T> type, Annotation... qualifiers)
static Object
getBeanReferenceByType(jakarta.enterprise.inject.spi.BeanManager beanManager, Type type, Annotation... qualifiers)
static jakarta.enterprise.inject.spi.InjectionPoint
getCurrentInjectionPoint(jakarta.enterprise.inject.spi.BeanManager beanManager, jakarta.enterprise.context.spi.CreationalContext<?> creationalContext)
Returns the current injection point.static Map<Class<?>,Class<? extends DataModel<?>>>
getDataModelClassesMap(jakarta.enterprise.inject.spi.CDI<Object> cdi)
static <A extends Annotation>
AgetQualifier(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint, Class<A> qualifierClass)
Returns the qualifier annotation of the given qualifier class from the given injection point.static <S extends Annotation>
booleanisScopeActive(Class<S> scope)
Returns true if given scope is active in current context.
-
Method Details
-
createConverter
public static Converter<?> createConverter(jakarta.enterprise.inject.spi.BeanManager beanManager, String value)Create a converter using the FacesConverter value attribute.- Parameters:
beanManager
- the bean manager.value
- the value attribute.- Returns:
- the converter, or null if we could not match one.
-
createConverter
public static Converter<?> createConverter(jakarta.enterprise.inject.spi.BeanManager beanManager, Class<?> forClass)Create a converter using the FacesConverter forClass attribute.- Parameters:
beanManager
- the bean manager.forClass
- the for class.- Returns:
- the converter, or null if we could not match one.
-
createBehavior
public static Behavior createBehavior(jakarta.enterprise.inject.spi.BeanManager beanManager, String value)Create a behavior using the FacesBehavior value attribute.- Parameters:
beanManager
- the bean manager.value
- the value attribute.- Returns:
- the behavior, or null if we could not match one.
-
createValidator
public static Validator<?> createValidator(jakarta.enterprise.inject.spi.BeanManager beanManager, String value)Create a validator using the FacesValidator value attribute.- Parameters:
beanManager
- the bean manager.value
- the value attribute.- Returns:
- the validator, or null if we could not match one.
-
addAnnotatedTypes
public static void addAnnotatedTypes(jakarta.enterprise.inject.spi.BeforeBeanDiscovery beforeBean, jakarta.enterprise.inject.spi.BeanManager beanManager, Class<?>... types) -
getBeanReference
-
getBeanReference
public static <T> T getBeanReference(jakarta.enterprise.inject.spi.BeanManager beanManager, Class<T> type, Annotation... qualifiers)- Parameters:
beanManager
- the bean managertype
- the required bean type the reference must havequalifier
- the required qualifiers the reference must have- Returns:
- a bean reference adhering to the required type and qualifiers
-
getBeanReferenceByType
public static Object getBeanReferenceByType(jakarta.enterprise.inject.spi.BeanManager beanManager, Type type, Annotation... qualifiers) -
getBeanInstance
Returns concrete (non-proxied) bean instance of given class in current context.- Parameters:
type
- the required bean type the instance must havecreate
- whether to auto-create bean if not exist- Returns:
- a bean instance adhering to the required type
-
getAnnotation
public static <A extends Annotation> Optional<A> getAnnotation(jakarta.enterprise.inject.spi.BeanManager beanManager, jakarta.enterprise.inject.spi.Annotated annotated, Class<A> annotationType)Finds an annotation in an Annotated, taking stereo types into account- Parameters:
beanManager
- the current bean managerannotated
- the Annotated in which to searchannotationType
- the type of the annotation to search for- Returns:
- An Optional that contains an instance of annotation type for which was searched if the annotated contained this.
-
createDataModel
-
getDataModelClassesMap
-
getCurrentInjectionPoint
public static jakarta.enterprise.inject.spi.InjectionPoint getCurrentInjectionPoint(jakarta.enterprise.inject.spi.BeanManager beanManager, jakarta.enterprise.context.spi.CreationalContext<?> creationalContext)Returns the current injection point. -
getQualifier
public static <A extends Annotation> A getQualifier(jakarta.enterprise.inject.spi.InjectionPoint injectionPoint, Class<A> qualifierClass)Returns the qualifier annotation of the given qualifier class from the given injection point. -
isScopeActive
Returns true if given scope is active in current context.
-