Class BeanConfigDecorator
- java.lang.Object
-
- de.cuioss.test.jsf.config.decorator.BeanConfigDecorator
-
public class BeanConfigDecorator extends Object
- Author:
- Oliver Wolff
-
-
Field Summary
Fields Modifier and Type Field Description static StringEL_STARTString constant used for checking if given String is EL-Expression.static StringEL_WRAPPERWraps textual names to EL-expressions.
-
Constructor Summary
Constructors Constructor Description BeanConfigDecorator(@NonNull FacesContext facesContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringcheckManagedBeanKey(String managedBeanKey)In case the beanKey is not an el expression (starting not with '#{') this method wraps the expression accordingly.static <T> TgetBean(String name, FacesContext facesContext, Class<T> expectedType)Utility method for accessing a concrete beanBeanConfigDecoratorregister(Object managedBean)Registers a given Object as jsf-managed bean.BeanConfigDecoratorregister(Object managedBean, String name)Registers a given Object as jsf-managed bean for the given key
-
-
-
Field Detail
-
EL_WRAPPER
public static final String EL_WRAPPER
Wraps textual names to EL-expressions.- See Also:
- Constant Field Values
-
EL_START
public static final String EL_START
String constant used for checking if given String is EL-Expression.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BeanConfigDecorator
public BeanConfigDecorator(@NonNull @NonNull FacesContext facesContext)
-
-
Method Detail
-
register
public BeanConfigDecorator register(Object managedBean, String name)
Registers a given Object as jsf-managed bean for the given key- Parameters:
managedBean- to be registered, must not be nullname- to be registered to. May be a correct value-expression or not (actual name only). Must not be null nor empty.- Returns:
- the
BeanConfigDecoratoritself in order to enable a fluent-api style usage
-
register
public BeanConfigDecorator register(Object managedBean)
Registers a given Object as jsf-managed bean. It checks the given bean for the annotationNamedin oder to extract the corresponding value attribute. If none could be found it uses theClass.getSimpleName()with the first letter being lower-cased- Parameters:
managedBean- to be registered, must not be null- Returns:
- the
BeanConfigDecoratoritself in order to enable a fluent-api style usage
-
checkManagedBeanKey
public static String checkManagedBeanKey(String managedBeanKey)
In case the beanKey is not an el expression (starting not with '#{') this method wraps the expression accordingly.- Parameters:
managedBeanKey- must not be null or empty- Returns:
- the key wrapped as an EL-Expression if needed, otherwise the given key.
-
getBean
public static <T> T getBean(String name, FacesContext facesContext, Class<T> expectedType)
Utility method for accessing a concrete bean- Parameters:
name- May be a correct value-expression or not (actual name only). Must not be null nor empty.facesContext- to be used for accessing the beanexpectedType- identifying the type to be checked- Returns:
- the registered bean for a given type or null, if none could be found
-
-