org.kuali.rice.krad.datadictionary
Class MessageBeanProcessor

java.lang.Object
  extended by org.kuali.rice.krad.datadictionary.DictionaryBeanProcessorBase
      extended by org.kuali.rice.krad.datadictionary.MessageBeanProcessor
All Implemented Interfaces:
DictionaryBeanProcessor

public class MessageBeanProcessor
extends DictionaryBeanProcessorBase

Dictionary bean processor that retrieves external messages for bean definitions and alters the bean definitions to use the external text

Author:
Kuali Rice Team (rice.collab@kuali.org)

Constructor Summary
MessageBeanProcessor(DataDictionary dataDictionary, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
           
 
Method Summary
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
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
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 definition
protected  void applyMessageToNestedListBean(Message message, List<?> listPropertyValue, String propertyPath)
          Applies a message to a nested list bean definition
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.
protected  String getComponentForBean(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition)
          Retrieves the component code associated with the bean definition
protected  String getMergedMessageText(String messageText, String propertyValue)
          Prepares the message text that will replace the property value checking for any expression placeholders
protected  MessageService getMessageService()
          Returns instance of the Message Service
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
protected  String getNamespaceForBean(String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition)
          Retrieves the namespace associated with the bean definition
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
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 value
 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)
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
 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
 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)
 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)
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
 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)
 void processRootBeanDefinition(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)
 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)
 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)
 
Methods inherited from class org.kuali.rice.krad.datadictionary.DictionaryBeanProcessorBase
applyPropertyValueToBean, applyPropertyValueToBean, getBeanClass, getDataDictionaryService, getPropertyValueBeanDefinition, getStringValue, isGeneratedBeanName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageBeanProcessor

public MessageBeanProcessor(DataDictionary dataDictionary,
                            org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Method Detail

processRootBeanDefinition

public void processRootBeanDefinition(String beanName,
                                      org.springframework.beans.factory.config.BeanDefinition beanDefinition)
Description copied from interface: DictionaryBeanProcessor
Invoked to process a root bean definition (a root bean definition is a top level bean)

Parameters:
beanName - name of the bean within the factory
beanDefinition - bean definition to process
See Also:
DictionaryBeanProcessor.processRootBeanDefinition(java.lang.String, org.springframework.beans.factory.config.BeanDefinition)

processNestedBeanDefinition

public void processNestedBeanDefinition(String beanName,
                                        org.springframework.beans.factory.config.BeanDefinition beanDefinition,
                                        String propertyName,
                                        Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack)
Description copied from interface: DictionaryBeanProcessor
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 factory
beanDefinition - bean definition to process
propertyName - the name of the property which has the bean definition value
nestedBeanStack - the stack of beans which contain the given bean
See Also:
DictionaryBeanProcessor#processNestedBeanDefinition(java.lang.String, org.springframework.beans.factory.config.BeanDefinition, java.lang.String, java.util.Stack)

processStringPropertyValue

public String processStringPropertyValue(String propertyName,
                                         String propertyValue,
                                         Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack)
Description copied from interface: DictionaryBeanProcessor
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 processed
propertyValue - string value for the property
Returns:
String new property value (possibly modified)
See Also:
DictionaryBeanProcessor#processStringPropertyValue(java.lang.String, java.lang.String, java.util.Stack)

processCollectionBeanDefinition

public void processCollectionBeanDefinition(String beanName,
                                            org.springframework.beans.factory.config.BeanDefinition beanDefinition,
                                            String propertyName,
                                            Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack)
Description copied from interface: DictionaryBeanProcessor
Invoked to process a collection value that is a bean definition

Parameters:
beanName - name of the bean within the factory
beanDefinition - bean definition within the collection to process
propertyName - the name of the property which has the collection value
nestedBeanStack - the stack of beans which contain the given collection (and collection bean)
See Also:
DictionaryBeanProcessor#processCollectionBeanDefinition(java.lang.String, org.springframework.beans.factory.config.BeanDefinition, java.lang.String, java.util.Stack)

processArrayStringPropertyValue

public String processArrayStringPropertyValue(String propertyName,
                                              Object[] propertyValue,
                                              String elementValue,
                                              int elementIndex,
                                              Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack)
Description copied from interface: DictionaryBeanProcessor
Invokes the processors to handle an array string value (which may be changed)

Parameters:
propertyName - name of the property that is being processed
propertyValue - the array which contains the string
elementValue - the string element value
elementIndex - the index of the string within the array
nestedBeanStack - the stack of bean containers, including the bean that contains the property
Returns:
String new property value (possibly modified by processors)
See Also:
DictionaryBeanProcessor#processArrayStringPropertyValue(java.lang.String, java.lang.Object[], java.lang.String, int, java.util.Stack)

processListStringPropertyValue

public String processListStringPropertyValue(String propertyName,
                                             List<?> propertyValue,
                                             String elementValue,
                                             int elementIndex,
                                             Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack)
Description copied from interface: DictionaryBeanProcessor
Invokes the processors to handle an list string value (which may be changed)

Parameters:
propertyName - name of the property that is being processed
propertyValue - the list which contains the string
elementValue - the string element value
elementIndex - the index of the string within the list
nestedBeanStack - the stack of bean containers, including the bean that contains the property
Returns:
String new property value (possibly modified by processors)
See Also:
DictionaryBeanProcessor#processListStringPropertyValue(java.lang.String, java.util.List, java.lang.String, int, java.util.Stack)

processSetStringPropertyValue

public String processSetStringPropertyValue(String propertyName,
                                            Set<?> propertyValue,
                                            String elementValue,
                                            Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack)
Description copied from interface: DictionaryBeanProcessor
Invokes the processors to handle an set string value (which may be changed)

Parameters:
propertyName - name of the property that is being processed
propertyValue - the set which contains the string
elementValue - the string element value
nestedBeanStack - the stack of bean containers, including the bean that contains the property
Returns:
String new property value (possibly modified by processors)
See Also:
DictionaryBeanProcessor#processSetStringPropertyValue(java.lang.String, java.util.Set, java.lang.String, java.util.Stack)

processMapStringPropertyValue

public String processMapStringPropertyValue(String propertyName,
                                            Map<?,?> propertyValue,
                                            String elementValue,
                                            Object elementKey,
                                            Stack<org.springframework.beans.factory.config.BeanDefinitionHolder> nestedBeanStack)
Description copied from interface: DictionaryBeanProcessor
Invokes the processors to handle an map string value (which may be changed)

Parameters:
propertyName - name of the property that is being processed
propertyValue - the map which contains the string
elementValue - the string element value
elementKey - the key for the string within the map
nestedBeanStack - the stack of bean containers, including the bean that contains the property
Returns:
String new property value (possibly modified by processors)
See Also:
DictionaryBeanProcessor#processMapStringPropertyValue(java.lang.String, java.util.Map, java.lang.String, java.lang.Object, java.util.Stack)

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 process
beanDefinition - bean definition to process
nestedBeanStack - 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 apply
beanDefinition - bean definition the message should be applied to
beanClass - 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 definition

The 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 apply
beanDefinition - bean definition containing the property
propertyPath - 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 definition

Here 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 apply
listPropertyValue - property value list that should contain the bean definition the message will be applied to
propertyPath - 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 value

Based 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 on
beanDefinition - 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 in
propertyName - 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 placeholders
nestedBeanStack - 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 stack
nestedBeanStack - 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 definition
messageText - - message text that will be the property value
beanDefinition - - bean definition to set property on

getMergedMessageText

protected String getMergedMessageText(String messageText,
                                      String propertyValue)
Prepares the message text that will replace the property value checking for any expression placeholders

The 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 message
propertyValue - - 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 for
beanDefinition - 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 for
beanDefinition - bean definition to find component code for
Returns:
String component code for bean or null if a component code was not found

getMessageService

protected MessageService getMessageService()
Returns instance of the Message Service

Returns:
MessageService isntanc


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.