Top Description Fields Constructors Methods
com.sun.faces.cdi

public final Class CdiUtils

extends Object
Class Inheritance
Static Imports
java.util.Optional.empty

A static utility class for CDI.

Field Summary

Modifier and TypeField and Description
private static final Type
private static final Logger
LOGGER

Stores the logger.

private static final Type

Constructor Summary

AccessConstructor and Description
private
CdiUtils()

Constructor.

Method Summary

Modifier and TypeMethod and Description
public static Behavior

Returns:

the behavior, or null if we could not match one.
createBehavior
(BeanManager
the bean manager.
beanManager
,
String
the value attribute.
value
)

Create a behavior using the FacesBehavior value attribute.

public static Converter<?>

Returns:

the converter, or null if we could not match one.
createConverter
(BeanManager
the bean manager.
beanManager
,
String
the value attribute.
value
)

Create a converter using the FacesConverter value attribute.

public static Converter<?>

Returns:

the converter, or null if we could not match one.
createConverter
(BeanManager
the bean manager.
beanManager
,
Class<?>
the for class.
forClass
)

Create a converter using the FacesConverter forClass attribute.

private static Converter<?>
createConverter(BeanManager beanManager, Annotation qualifier)

public static DataModel<?>
createDataModel(final Class<?> forClass)

public static Validator<?>

Returns:

the validator, or null if we could not match one.
createValidator
(BeanManager
the bean manager.
beanManager
,
String
the value attribute.
value
)

Create a validator using the FacesValidator value attribute.

public static <A extends Annotation> Optional<A>

Returns:

An Optional that contains an instance of annotation type for which was searched if the annotated contained this.
getAnnotation
(BeanManager
the current bean manager
beanManager
,
Annotated
the Annotated in which to search
annotated
,
Class<A>
the type of the annotation to search for
annotationType
)

Finds an annotation in an Annotated, taking stereo types into account

public static <T> T

Returns:

a bean instance adhering to the required type
getBeanInstance
(Class<T>
the required bean type the instance must have
type
,
boolean
whether to auto-create bean if not exist
create
)

Returns concrete (non-proxied) bean instance of given class in current context.

public static <T> T
getBeanReference(Class<T> type, Annotation... qualifiers)

public static <T> T

Returns:

a bean reference adhering to the required type and qualifiers
getBeanReference
(BeanManager
the bean manager
beanManager
,
Class<T>
the required bean type the reference must have
type
,
Annotation...
the required qualifiers the reference must have
qualifiers
)

public static Object
getBeanReferenceByType(BeanManager beanManager, Type type, Annotation... qualifiers)

public static InjectionPoint
getCurrentInjectionPoint(BeanManager beanManager, CreationalContext<?> creationalContext)

Returns the current injection point.

public static Map<Class<?>, Class<? extends DataModel<?>>>
public static <A extends Annotation> A
getQualifier(InjectionPoint injectionPoint, Class<A> qualifierClass)

Returns the qualifier annotation of the given qualifier class from the given injection point.

public static <S extends Annotation> boolean
isScopeActive(Class<S> scope)

Returns true if given scope is active in current context.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CONVERTER_TYPEback to summary
private static final Type CONVERTER_TYPE
LOGGERback to summary
private static final Logger LOGGER

Stores the logger.

VALIDATOR_TYPEback to summary
private static final Type VALIDATOR_TYPE

Constructor Detail

CdiUtilsback to summary
private CdiUtils()

Constructor.

Method Detail

createBehaviorback to summary
public static Behavior createBehavior(BeanManager beanManager, String value)

Create a behavior using the FacesBehavior value attribute.

Parameters
beanManager:BeanManager

the bean manager.

value:String

the value attribute.

Returns:Behavior

the behavior, or null if we could not match one.

createConverterback to summary
public static Converter<?> createConverter(BeanManager beanManager, String value)

Create a converter using the FacesConverter value attribute.

Parameters
beanManager:BeanManager

the bean manager.

value:String

the value attribute.

Returns:Converter<?>

the converter, or null if we could not match one.

createConverterback to summary
public static Converter<?> createConverter(BeanManager beanManager, Class<?> forClass)

Create a converter using the FacesConverter forClass attribute.

Parameters
beanManager:BeanManager

the bean manager.

forClass:Class<?>

the for class.

Returns:Converter<?>

the converter, or null if we could not match one.

createConverterback to summary
private static Converter<?> createConverter(BeanManager beanManager, Annotation qualifier)
createDataModelback to summary
public static DataModel<?> createDataModel(final Class<?> forClass)
createValidatorback to summary
public static Validator<?> createValidator(BeanManager beanManager, String value)

Create a validator using the FacesValidator value attribute.

Parameters
beanManager:BeanManager

the bean manager.

value:String

the value attribute.

Returns:Validator<?>

the validator, or null if we could not match one.

getAnnotationback to summary
public static <A extends Annotation> Optional<A> getAnnotation(BeanManager beanManager, Annotated annotated, Class<A> annotationType)

Finds an annotation in an Annotated, taking stereo types into account

Parameters
beanManager:BeanManager

the current bean manager

annotated:Annotated

the Annotated in which to search

annotationType:Class<A>

the type of the annotation to search for

Returns:Optional<A>

An Optional that contains an instance of annotation type for which was searched if the annotated contained this.

getBeanInstanceback to summary
public static <T> T getBeanInstance(Class<T> type, boolean create)

Returns concrete (non-proxied) bean instance of given class in current context.

Parameters
type:Class<T>

the required bean type the instance must have

create:boolean

whether to auto-create bean if not exist

Returns:T

a bean instance adhering to the required type

getBeanReferenceback to summary
public static <T> T getBeanReference(Class<T> type, Annotation... qualifiers)
getBeanReferenceback to summary
public static <T> T getBeanReference(BeanManager beanManager, Class<T> type, Annotation... qualifiers)
Parameters
beanManager:BeanManager

the bean manager

type:Class<T>

the required bean type the reference must have

qualifiers:Annotation[]

the required qualifiers the reference must have

Returns:T

a bean reference adhering to the required type and qualifiers

getBeanReferenceByTypeback to summary
public static Object getBeanReferenceByType(BeanManager beanManager, Type type, Annotation... qualifiers)
getCurrentInjectionPointback to summary
public static InjectionPoint getCurrentInjectionPoint(BeanManager beanManager, CreationalContext<?> creationalContext)

Returns the current injection point.

getDataModelClassesMapback to summary
public static Map<Class<?>, Class<? extends DataModel<?>>> getDataModelClassesMap(CDI<Object> cdi)
Annotations
@SuppressWarnings:unchecked
getQualifierback to summary
public static <A extends Annotation> A getQualifier(InjectionPoint injectionPoint, Class<A> qualifierClass)

Returns the qualifier annotation of the given qualifier class from the given injection point.

isScopeActiveback to summary
public static <S extends Annotation> boolean isScopeActive(Class<S> scope)

Returns true if given scope is active in current context.