Class MessageBeanProcessor
- All Implemented Interfaces:
DictionaryBeanProcessor
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Constructor Summary
ConstructorsConstructorDescriptionMessageBeanProcessor(DataDictionary dataDictionary, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyMessageTextToPropertyValue(String propertyName, String messageText, org.springframework.beans.factory.config.BeanDefinition beanDefinition) Applies the given message text to the bean definition with the given property name, if a current value exists for the property name the value is checked for expressions which are then merged with the messageprotected voidapplyMessageToBean(Message message, org.springframework.beans.factory.config.BeanDefinition beanDefinition, Class<?> beanClass) Applies the text for a given message to the associated bean definition propertyprotected voidapplyMessageToNestedBean(Message message, org.springframework.beans.factory.config.BeanDefinition beanDefinition, String propertyPath) Applies the given message text to the property within the given bean definitionprotected voidapplyMessageToNestedListBean(Message message, List<?> listPropertyValue, String propertyPath) Applies a message to a nested list bean definitionprotected StringfindPropertyValueInBeanDefinition(org.springframework.beans.factory.config.BeanDefinition beanDefinition, String propertyName) Attempts to find a property value for the given property name within the bean definition, if the property does not exist in the bean and there is a parent, the parent is checked for containing the property.protected StringgetComponentForBean(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition) Retrieves the component code associated with the bean definitionprotected StringgetMergedMessageText(String messageText, String propertyValue) Prepares the message text that will replace the property value checking for any expression placeholdersprotected MessageServiceReturns instance of the Message Serviceprotected StringgetMessageTextForKey(String messageKeyStr, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Retrieves the test associated with the message give by the message key stringprotected StringgetNamespaceForBean(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition) Retrieves the namespace associated with the bean definitionprotected StringgetNamespaceForBeanInStack(Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Walks up the stack of bean definitions until a namespace is found and returns that namespaceprotected booleanisBeanMessageMatch(String matchListIdentifierPropertyValue, org.springframework.beans.factory.config.BeanDefinition beanDefinition) Determines whether the given bean definition is a matched based on the given identifier valueprocessArrayStringPropertyValue(String propertyName, Object[] propertyValue, String elementValue, int elementIndex, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invokes the processors to handle an array string value (which may be changed)protected voidprocessBeanMessages(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Retrieves external messages whose namespace and component matches the bean definition and applies the message text to the bean property valuesvoidprocessCollectionBeanDefinition(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition, String propertyName, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invoked to process a collection value that is a bean definitionprocessListStringPropertyValue(String propertyName, List<?> propertyValue, String elementValue, int elementIndex, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invokes the processors to handle an list string value (which may be changed)processMapStringPropertyValue(String propertyName, Map<?, ?> propertyValue, String elementValue, Object elementKey, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invokes the processors to handle an map string value (which may be changed)protected StringprocessMessagePlaceholders(String propertyValue, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Checks a string property value for a message placeholder and if found the message is retrieved and updated in the property valuevoidprocessNestedBeanDefinition(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition, String propertyName, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invoked to process a nested bean definition (a bean definition that is a property value of another bean definition)voidprocessRootBeanDefinition(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition) Invoked to process a root bean definition (a root bean definition is a top level bean)processSetStringPropertyValue(String propertyName, Set<?> propertyValue, String elementValue, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invokes the processors to handle an set string value (which may be changed)processStringPropertyValue(String propertyName, String propertyValue, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invoked to process a string property value (straight property value, not a string within a collection)Methods inherited from class org.kuali.rice.krad.datadictionary.DictionaryBeanProcessorBase
applyPropertyValueToBean, applyPropertyValueToBean, getBeanClass, getDataDictionaryService, getPropertyValueBeanDefinition, getStringValue, isGeneratedBeanName
-
Constructor Details
-
MessageBeanProcessor
public MessageBeanProcessor(DataDictionary dataDictionary, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
-
-
Method Details
-
processRootBeanDefinition
public void processRootBeanDefinition(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition) Description copied from interface:DictionaryBeanProcessorInvoked to process a root bean definition (a root bean definition is a top level bean)- Parameters:
beanName- name of the bean within the factorybeanDefinition- bean definition to process- See Also:
-
processNestedBeanDefinition
public void processNestedBeanDefinition(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition, String propertyName, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invoked to process a nested bean definition (a bean definition that is a property value of another bean definition)- Parameters:
beanName- name of the bean within the factorybeanDefinition- bean definition to processpropertyName- the name of the property which has the bean definition valuenestedBeanStack- the stack of beans which contain the given bean
-
processStringPropertyValue
public String processStringPropertyValue(String propertyName, String propertyValue, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invoked to process a string property value (straight property value, not a string within a collection)- Parameters:
propertyName- name of the property whose string value is being processedpropertyValue- string value for the property- Returns:
- String new property value (possibly modified)
-
processCollectionBeanDefinition
public void processCollectionBeanDefinition(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition, String propertyName, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invoked to process a collection value that is a bean definition- Parameters:
beanName- name of the bean within the factorybeanDefinition- bean definition within the collection to processpropertyName- the name of the property which has the collection valuenestedBeanStack- the stack of beans which contain the given collection (and collection bean)
-
processArrayStringPropertyValue
public String processArrayStringPropertyValue(String propertyName, Object[] propertyValue, String elementValue, int elementIndex, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invokes the processors to handle an array string value (which may be changed)- Parameters:
propertyName- name of the property that is being processedpropertyValue- the array which contains the stringelementValue- the string element valueelementIndex- the index of the string within the arraynestedBeanStack- the stack of bean containers, including the bean that contains the property- Returns:
- String new property value (possibly modified by processors)
-
processListStringPropertyValue
public String processListStringPropertyValue(String propertyName, List<?> propertyValue, String elementValue, int elementIndex, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invokes the processors to handle an list string value (which may be changed)- Parameters:
propertyName- name of the property that is being processedpropertyValue- the list which contains the stringelementValue- the string element valueelementIndex- the index of the string within the listnestedBeanStack- the stack of bean containers, including the bean that contains the property- Returns:
- String new property value (possibly modified by processors)
-
processSetStringPropertyValue
public String processSetStringPropertyValue(String propertyName, Set<?> propertyValue, String elementValue, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invokes the processors to handle an set string value (which may be changed)- Parameters:
propertyName- name of the property that is being processedpropertyValue- the set which contains the stringelementValue- the string element valuenestedBeanStack- the stack of bean containers, including the bean that contains the property- Returns:
- String new property value (possibly modified by processors)
-
processMapStringPropertyValue
public String processMapStringPropertyValue(String propertyName, Map<?, ?> propertyValue, String elementValue, Object elementKey, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Invokes the processors to handle an map string value (which may be changed)- Parameters:
propertyName- name of the property that is being processedpropertyValue- the map which contains the stringelementValue- the string element valueelementKey- the key for the string within the mapnestedBeanStack- the stack of bean containers, including the bean that contains the property- Returns:
- String new property value (possibly modified by processors)
-
processBeanMessages
protected void processBeanMessages(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Retrieves external messages whose namespace and component matches the bean definition and applies the message text to the bean property values- Parameters:
beanName- name of the bean to processbeanDefinition- bean definition to processnestedBeanStack- stack of beans that contain the given bean, used for finding a namespace
-
applyMessageToBean
protected void applyMessageToBean(Message message, org.springframework.beans.factory.config.BeanDefinition beanDefinition, Class<?> beanClass) Applies the text for a given message to the associated bean definition property- Parameters:
message- message instance to applybeanDefinition- bean definition the message should be applied tobeanClass- class for the bean definition
-
applyMessageToNestedBean
protected void applyMessageToNestedBean(Message message, org.springframework.beans.factory.config.BeanDefinition beanDefinition, String propertyPath) Applies the given message text to the property within the given bean definitionThe message text is applied to the bean definiton based on the property path. The path could be nested in which case the property values of the bean definition are traversed to find the nested bean definition that should hold the property value. The path could also represent a nested list bean. In this case a helper method is called to find the correct list bean to apply the message to
- Parameters:
message- message containing the text to applybeanDefinition- bean definition containing the propertypropertyPath- path to property within the bean definition the message should be applied to
-
applyMessageToNestedListBean
protected void applyMessageToNestedListBean(Message message, List<?> listPropertyValue, String propertyPath) Applies a message to a nested list bean definitionHere the property path first gives an identifier value (such as property name) to use for finding the bean definition with the list the message should apply to. Any part of the path after the identifier value is treated like a nested property path
- Parameters:
message- message instance that contains the text to applylistPropertyValue- property value list that should contain the bean definition the message will be applied topropertyPath- path to the bean definition the message should apply to
-
isBeanMessageMatch
protected boolean isBeanMessageMatch(String matchListIdentifierPropertyValue, org.springframework.beans.factory.config.BeanDefinition beanDefinition) Determines whether the given bean definition is a matched based on the given identifier valueBased on the class for the bean definition an identifier property name is used, the corresponding value from the bean definition is then retrieved and compared to the given value to determine whether the bean definition is a match
- Parameters:
matchListIdentifierPropertyValue- property value to match bean definitions onbeanDefinition- bean definition to determine the match for- Returns:
- boolean true if the bean definition is a match, false if not
-
findPropertyValueInBeanDefinition
protected String findPropertyValueInBeanDefinition(org.springframework.beans.factory.config.BeanDefinition beanDefinition, String propertyName) Attempts to find a property value for the given property name within the bean definition, if the property does not exist in the bean and there is a parent, the parent is checked for containing the property. This continues until a property value is found or all the parents have been traversed- Parameters:
beanDefinition- bean definition to find property value inpropertyName- name of the property to find the value for- Returns:
- String value for property in the bean definition or null if the property was not found
-
processMessagePlaceholders
protected String processMessagePlaceholders(String propertyValue, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Checks a string property value for a message placeholder and if found the message is retrieved and updated in the property value- Parameters:
propertyValue- string value to process for message placeholdersnestedBeanStack- stack of bean definitions that contain the property, used to determine the namespace and component for the message retrieval- Returns:
- String new value for the property (possibly modified from an external message)
-
getMessageTextForKey
protected String getMessageTextForKey(String messageKeyStr, Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Retrieves the test associated with the message give by the message key string- Parameters:
messageKeyStr- key string for the message, can contain just the key, or also the component and/or namespace. If component or namespace not given it is determined from the bean stacknestedBeanStack- bean stack that contains the property for which the message applies- Returns:
- String test associated with the message
-
applyMessageTextToPropertyValue
protected void applyMessageTextToPropertyValue(String propertyName, String messageText, org.springframework.beans.factory.config.BeanDefinition beanDefinition) Applies the given message text to the bean definition with the given property name, if a current value exists for the property name the value is checked for expressions which are then merged with the message- Parameters:
propertyName- - name of the property to set on the bean definitionmessageText- - message text that will be the property valuebeanDefinition- - bean definition to set property on
-
getMergedMessageText
Prepares the message text that will replace the property value checking for any expression placeholdersThe message text may contain placeholders (using brace delimiters) for expression placement. It is expected when these placeholders are given the property value contains the expressions (using the expression placeholders) that will be inserted into the message text
- Parameters:
messageText- - raw text of the messagepropertyValue- - current value for the property- Returns:
- String the message text with expressions inserted (if any expressions were found)
-
getNamespaceForBeanInStack
protected String getNamespaceForBeanInStack(Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack) Walks up the stack of bean definitions until a namespace is found and returns that namespace- Parameters:
nestedBeanStack- stack of bean definitions to find namespace for- Returns:
- String namespace found in stack or null if one was not found
-
getNamespaceForBean
protected String getNamespaceForBean(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition) Retrieves the namespace associated with the bean definition- Parameters:
beanName- name of the bean to find namespace forbeanDefinition- bean definition to find namespace for- Returns:
- String namespace for bean or null if a namespace was not found
-
getComponentForBean
protected String getComponentForBean(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition) Retrieves the component code associated with the bean definition- Parameters:
beanName- name of the bean to find component code forbeanDefinition- bean definition to find component code for- Returns:
- String component code for bean or null if a component code was not found
-
getMessageService
Returns instance of the Message Service- Returns:
- MessageService isntanc
-