|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.kuali.rice.krad.uif.util.UifBeanFactoryPostProcessor
public class UifBeanFactoryPostProcessor
Post processes the bean factory to handle UIF property expressions and IDs on inner beans
Conditional logic can be implemented with the UIF dictionary by means of property expressions. These are expressions that follow SPEL and can be given as the value for a property using the @{} placeholder. Since such a value would cause an exception when creating the object if the property is a non-string type (value cannot be converted), we need to move those expressions to a Map for processing, and then remove the original property configuration containing the expression. The expressions are then evaluated during the view apply model phase and the result is set as the value for the corresponding property.
Spring will not register inner beans with IDs so that the bean definition can be retrieved through the factory, therefore this post processor adds them as top level registered beans
TODO: convert to dictionary bean processor
Constructor Summary | |
---|---|
UifBeanFactoryPostProcessor()
|
Method Summary | |
---|---|
protected Class<?> |
getBeanClass(org.springframework.beans.factory.config.BeanDefinition beanDefinition,
org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Retrieves the class for the object that will be created from the bean definition. |
protected Map<String,String> |
getExpressionGraphFromParent(String parentBeanName,
org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory,
Set<String> processedBeanNames)
Retrieves the expression graph map set on the bean with given name. |
protected String |
getStringValue(Object value)
Determines whether the given value is of String type and if so returns the string value |
protected boolean |
hasExpression(Object propertyValue)
Checks whether the given property value is of String type, and if so whether it contains the expression placholder(s) |
void |
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Iterates through all beans in the factory and invokes processing |
protected void |
processBeanDefinition(String beanName,
org.springframework.beans.factory.config.BeanDefinition beanDefinition,
org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory,
Set<String> processedBeanNames)
Processes a top level (non nested) bean definition for expressions |
protected void |
processNestedBeanDefinition(String beanName,
org.springframework.beans.factory.config.BeanDefinition beanDefinition,
String nestedPropertyName,
Map<String,String> expressionGraph,
org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory,
Set<String> processedBeanNames)
If the bean class is type UifDictionaryBean, iterate through configured property values and check for expressions |
protected Object |
processPropertyValue(String nestedPropertyName,
String propertyName,
Object propertyValue,
org.springframework.beans.factory.config.BeanDefinition beanDefinition,
Map<String,String> parentExpressionGraph,
Map<String,String> expressionGraph,
org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory,
Set<String> processedBeanNames)
Processes the given property name/value pair for complex objects, such as bean definitions or collections, which if found will be processed for contained property expression values |
protected void |
removeExpressionsByPrefix(String propertyNamePrefix,
Map<String,String> expressionGraph)
Removes entries from the given expressions map whose key starts with the given prefix |
protected void |
visitArray(String propertyName,
Map<String,String> parentExpressionGraph,
Map<String,String> expressionGraph,
Object array,
org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory,
Set<String> processedBeanNames)
|
protected void |
visitList(String nestedPropertyName,
String propertyName,
org.springframework.beans.factory.config.BeanDefinition beanDefinition,
Map<String,String> parentExpressionGraph,
Map<String,String> expressionGraph,
List listVal,
org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory,
Set<String> processedBeanNames)
|
protected void |
visitMap(String propertyName,
Map<String,String> parentExpressionGraph,
Map<String,String> expressionGraph,
Map<?,?> mapVal,
org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory,
Set<String> processedBeanNames)
|
protected void |
visitSet(String propertyName,
Map<String,String> parentPropertyExpressions,
Map<String,String> propertyExpressions,
Set setVal,
org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory,
Set<String> processedBeanNames)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UifBeanFactoryPostProcessor()
Method Detail |
---|
public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException
postProcessBeanFactory
in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
beanFactory
- - bean factory instance to process
org.springframework.beans.BeansException
protected void processBeanDefinition(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames)
A bean that is non nested (or top of a collection) will hold all the expressions for the graph. A new expression graph is initialized and expressions are collected as the bean and all its children are processed. The expression graph is then set as a property on the top bean definition
beanName
- - name of the bean to processbeanDefinition
- - bean definition to processbeanFactory
- - factory holding all the bean definitionsprocessedBeanNames
- - set of bean names that have already been processedprotected void processNestedBeanDefinition(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition, String nestedPropertyName, Map<String,String> expressionGraph, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames)
beanName
- - name of the bean in the factory (only set for top level beans, not nested)beanDefinition
- - bean definition to process for expressionsnestedPropertyName
- expressionGraph
- beanFactory
- - bean factory being processedprocessedBeanNames
- protected Class<?> getBeanClass(org.springframework.beans.factory.config.BeanDefinition beanDefinition, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
beanDefinition
- - bean definition to get class forbeanFactory
- - bean factory that contains the bean definition
protected Map<String,String> getExpressionGraphFromParent(String parentBeanName, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames)
parentBeanName
- - name of the parent bean to retrieve map for (if empty a new map will be returned)beanFactory
- - bean factory to retrieve bean definition fromprocessedBeanNames
- - set of bean names that have been processed so far
protected boolean hasExpression(Object propertyValue)
propertyValue
- - value to check for expressions
protected Object processPropertyValue(String nestedPropertyName, String propertyName, Object propertyValue, org.springframework.beans.factory.config.BeanDefinition beanDefinition, Map<String,String> parentExpressionGraph, Map<String,String> expressionGraph, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames)
nestedPropertyName
- - nested path of the property whose value is being processedpropertyName
- - name of the property in the bean definition being processedpropertyValue
- - value to checkbeanDefinition
- - bean definition the property belongs toparentExpressionGraph
- - map that holds property expressions for the parent bean definition, used for
mergingexpressionGraph
- - map that holds property expressions for the bean definition being processedbeanFactory
- - bean factory that contains the bean definition being processedprocessedBeanNames
- - set of bean names that have been processed so far
protected void removeExpressionsByPrefix(String propertyNamePrefix, Map<String,String> expressionGraph)
propertyNamePrefix
- - prefix to search for and removeexpressionGraph
- - map of property expressions to filterprotected String getStringValue(Object value)
value
- - object value to check
protected void visitArray(String propertyName, Map<String,String> parentExpressionGraph, Map<String,String> expressionGraph, Object array, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames)
protected void visitList(String nestedPropertyName, String propertyName, org.springframework.beans.factory.config.BeanDefinition beanDefinition, Map<String,String> parentExpressionGraph, Map<String,String> expressionGraph, List listVal, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames)
protected void visitSet(String propertyName, Map<String,String> parentPropertyExpressions, Map<String,String> propertyExpressions, Set setVal, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames)
protected void visitMap(String propertyName, Map<String,String> parentExpressionGraph, Map<String,String> expressionGraph, Map<?,?> mapVal, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |