| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.krad.uif.util; |
| 17 | |
|
| 18 | |
import org.apache.commons.lang.StringUtils; |
| 19 | |
import org.apache.commons.logging.Log; |
| 20 | |
import org.apache.commons.logging.LogFactory; |
| 21 | |
import org.kuali.rice.krad.datadictionary.DataDictionary; |
| 22 | |
import org.kuali.rice.krad.uif.UifConstants; |
| 23 | |
import org.kuali.rice.krad.uif.UifPropertyPaths; |
| 24 | |
import org.kuali.rice.krad.uif.component.Configurable; |
| 25 | |
import org.springframework.beans.BeansException; |
| 26 | |
import org.springframework.beans.MutablePropertyValues; |
| 27 | |
import org.springframework.beans.PropertyValue; |
| 28 | |
import org.springframework.beans.factory.config.BeanDefinition; |
| 29 | |
import org.springframework.beans.factory.config.BeanDefinitionHolder; |
| 30 | |
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; |
| 31 | |
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; |
| 32 | |
import org.springframework.beans.factory.config.TypedStringValue; |
| 33 | |
import org.springframework.beans.factory.support.GenericBeanDefinition; |
| 34 | |
import org.springframework.beans.factory.support.ManagedList; |
| 35 | |
import org.springframework.beans.factory.support.ManagedMap; |
| 36 | |
|
| 37 | |
import java.util.ArrayList; |
| 38 | |
import java.util.HashMap; |
| 39 | |
import java.util.HashSet; |
| 40 | |
import java.util.LinkedHashMap; |
| 41 | |
import java.util.LinkedHashSet; |
| 42 | |
import java.util.List; |
| 43 | |
import java.util.Map; |
| 44 | |
import java.util.Set; |
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | 0 | public class UifBeanFactoryPostProcessor implements BeanFactoryPostProcessor { |
| 61 | 0 | private static final Log LOG = LogFactory.getLog(UifBeanFactoryPostProcessor.class); |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
@Override |
| 70 | |
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { |
| 71 | 0 | Set<String> processedBeanNames = new HashSet<String>(); |
| 72 | |
|
| 73 | 0 | LOG.info("Beginning post processing of bean factory for UIF expressions"); |
| 74 | |
|
| 75 | 0 | String[] beanNames = beanFactory.getBeanDefinitionNames(); |
| 76 | 0 | for (int i = 0; i < beanNames.length; i++) { |
| 77 | 0 | String beanName = beanNames[i]; |
| 78 | 0 | BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName); |
| 79 | |
|
| 80 | 0 | processBeanDefinition(beanName, beanDefinition, beanFactory, processedBeanNames); |
| 81 | |
} |
| 82 | |
|
| 83 | 0 | LOG.info("Finished post processing of bean factory for UIF expressions"); |
| 84 | 0 | } |
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
protected void processBeanDefinition(String beanName, BeanDefinition beanDefinition, |
| 100 | |
ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames) { |
| 101 | 0 | Class<?> beanClass = getBeanClass(beanDefinition, beanFactory); |
| 102 | 0 | if ((beanClass == null) || !Configurable.class.isAssignableFrom(beanClass)) { |
| 103 | 0 | return; |
| 104 | |
} |
| 105 | |
|
| 106 | 0 | if (processedBeanNames.contains(beanName)) { |
| 107 | 0 | return; |
| 108 | |
} |
| 109 | |
|
| 110 | 0 | LOG.debug("Processing bean name '" + beanName + "'"); |
| 111 | |
|
| 112 | 0 | MutablePropertyValues pvs = beanDefinition.getPropertyValues(); |
| 113 | |
|
| 114 | 0 | if (pvs.getPropertyValue(UifPropertyPaths.PROPERTY_EXPRESSIONS) != null) { |
| 115 | |
|
| 116 | 0 | return; |
| 117 | |
} |
| 118 | |
|
| 119 | 0 | Map<String, String> propertyExpressions = new ManagedMap<String, String>(); |
| 120 | 0 | Map<String, String> parentPropertyExpressions = getPropertyExpressionsFromParent(beanDefinition.getParentName(), |
| 121 | |
beanFactory, processedBeanNames); |
| 122 | 0 | boolean parentExpressionsExist = !parentPropertyExpressions.isEmpty(); |
| 123 | |
|
| 124 | 0 | PropertyValue[] pvArray = pvs.getPropertyValues(); |
| 125 | 0 | for (PropertyValue pv : pvArray) { |
| 126 | 0 | if (hasExpression(pv.getValue())) { |
| 127 | |
|
| 128 | 0 | String strValue = getStringValue(pv.getValue()); |
| 129 | 0 | propertyExpressions.put(pv.getName(), strValue); |
| 130 | |
|
| 131 | |
|
| 132 | 0 | pvs.removePropertyValue(pv.getName()); |
| 133 | 0 | } else { |
| 134 | |
|
| 135 | 0 | Object newValue = processPropertyValue(pv.getName(), pv.getValue(), parentPropertyExpressions, |
| 136 | |
propertyExpressions, beanFactory, processedBeanNames); |
| 137 | 0 | pvs.removePropertyValue(pv.getName()); |
| 138 | 0 | pvs.addPropertyValue(pv.getName(), newValue); |
| 139 | |
} |
| 140 | |
|
| 141 | |
|
| 142 | 0 | if (parentPropertyExpressions.containsKey(pv.getName())) { |
| 143 | 0 | parentPropertyExpressions.remove(pv.getName()); |
| 144 | |
} |
| 145 | |
|
| 146 | |
|
| 147 | 0 | if (StringUtils.contains(pv.getName(), ".")) { |
| 148 | |
|
| 149 | |
} |
| 150 | |
} |
| 151 | |
|
| 152 | 0 | if (!propertyExpressions.isEmpty() || parentExpressionsExist) { |
| 153 | |
|
| 154 | 0 | ManagedMap<String, String> mergedPropertyExpressions = new ManagedMap<String, String>(); |
| 155 | 0 | mergedPropertyExpressions.setMergeEnabled(false); |
| 156 | 0 | mergedPropertyExpressions.putAll(parentPropertyExpressions); |
| 157 | 0 | mergedPropertyExpressions.putAll(propertyExpressions); |
| 158 | |
|
| 159 | 0 | pvs.addPropertyValue(UifPropertyPaths.PROPERTY_EXPRESSIONS, mergedPropertyExpressions); |
| 160 | |
} |
| 161 | |
|
| 162 | 0 | if (StringUtils.isNotBlank(beanName)) { |
| 163 | 0 | processedBeanNames.add(beanName); |
| 164 | |
} |
| 165 | 0 | } |
| 166 | |
|
| 167 | |
protected void removeParentExpressionsOnNested(String propertyName, MutablePropertyValues pvs, |
| 168 | |
String parentBeanName, ConfigurableListableBeanFactory beanFactory) { |
| 169 | 0 | BeanDefinition parentBeanDefinition = beanFactory.getMergedBeanDefinition(parentBeanName); |
| 170 | |
|
| 171 | |
|
| 172 | 0 | MutablePropertyValues parentPvs = parentBeanDefinition.getPropertyValues(); |
| 173 | 0 | PropertyValue[] pvArray = parentPvs.getPropertyValues(); |
| 174 | 0 | for (PropertyValue pv : pvArray) { |
| 175 | 0 | boolean isNameMatch = false; |
| 176 | 0 | String nestedPropertyName = ""; |
| 177 | 0 | if (propertyName.startsWith(pv.getName())) { |
| 178 | 0 | nestedPropertyName = StringUtils.removeStart(propertyName, pv.getName()); |
| 179 | 0 | if (nestedPropertyName.startsWith(".")) { |
| 180 | 0 | nestedPropertyName = StringUtils.removeStart(nestedPropertyName, "."); |
| 181 | 0 | isNameMatch = true; |
| 182 | |
} |
| 183 | |
} |
| 184 | |
|
| 185 | |
|
| 186 | 0 | if (isNameMatch && ((pv.getValue() instanceof BeanDefinition) || (pv |
| 187 | |
.getValue() instanceof BeanDefinitionHolder))) { |
| 188 | |
BeanDefinition propertyBeanDefinition; |
| 189 | 0 | if (pv.getValue() instanceof BeanDefinition) { |
| 190 | 0 | propertyBeanDefinition = (BeanDefinition) pv.getValue(); |
| 191 | |
} else { |
| 192 | 0 | propertyBeanDefinition = ((BeanDefinitionHolder) pv.getValue()).getBeanDefinition(); |
| 193 | |
} |
| 194 | |
|
| 195 | 0 | MutablePropertyValues nestedPvs = propertyBeanDefinition.getPropertyValues(); |
| 196 | 0 | if (nestedPvs.contains(UifPropertyPaths.PROPERTY_EXPRESSIONS)) { |
| 197 | 0 | PropertyValue propertyExpressionsPV = nestedPvs.getPropertyValue( |
| 198 | |
UifPropertyPaths.PROPERTY_EXPRESSIONS); |
| 199 | 0 | if (propertyExpressionsPV != null) { |
| 200 | 0 | Object value = propertyExpressionsPV.getValue(); |
| 201 | 0 | if ((value != null) && (value instanceof ManagedMap)) { |
| 202 | 0 | Map<String, String> nestedPropertyExpressions = (ManagedMap) value; |
| 203 | 0 | if (nestedPropertyExpressions.containsKey(nestedPropertyName)) { |
| 204 | |
|
| 205 | 0 | ManagedMap<String, String> copiedPropertyExpressions = new ManagedMap<String, String>(); |
| 206 | 0 | copiedPropertyExpressions.setMergeEnabled(false); |
| 207 | 0 | copiedPropertyExpressions.putAll(nestedPropertyExpressions); |
| 208 | 0 | copiedPropertyExpressions.remove(nestedPropertyName); |
| 209 | |
|
| 210 | 0 | BeanDefinition copiedBeanDefinition = new GenericBeanDefinition(propertyBeanDefinition); |
| 211 | 0 | copiedBeanDefinition.getPropertyValues().add(UifPropertyPaths.PROPERTY_EXPRESSIONS, |
| 212 | |
copiedPropertyExpressions); |
| 213 | |
|
| 214 | 0 | pvs.add(pv.getName(), copiedBeanDefinition); |
| 215 | |
} |
| 216 | |
} |
| 217 | |
} |
| 218 | |
} |
| 219 | |
} |
| 220 | |
} |
| 221 | 0 | } |
| 222 | |
|
| 223 | |
|
| 224 | |
|
| 225 | |
|
| 226 | |
|
| 227 | |
|
| 228 | |
|
| 229 | |
|
| 230 | |
|
| 231 | |
|
| 232 | |
protected Class<?> getBeanClass(BeanDefinition beanDefinition, ConfigurableListableBeanFactory beanFactory) { |
| 233 | 0 | if (StringUtils.isNotBlank(beanDefinition.getBeanClassName())) { |
| 234 | |
try { |
| 235 | 0 | return Class.forName(beanDefinition.getBeanClassName()); |
| 236 | 0 | } catch (ClassNotFoundException e) { |
| 237 | |
|
| 238 | 0 | return null; |
| 239 | |
} |
| 240 | 0 | } else if (StringUtils.isNotBlank(beanDefinition.getParentName())) { |
| 241 | 0 | BeanDefinition parentBeanDefinition = beanFactory.getBeanDefinition(beanDefinition.getParentName()); |
| 242 | 0 | if (parentBeanDefinition != null) { |
| 243 | 0 | return getBeanClass(parentBeanDefinition, beanFactory); |
| 244 | |
} |
| 245 | |
} |
| 246 | |
|
| 247 | 0 | return null; |
| 248 | |
} |
| 249 | |
|
| 250 | |
|
| 251 | |
|
| 252 | |
|
| 253 | |
|
| 254 | |
|
| 255 | |
|
| 256 | |
|
| 257 | |
|
| 258 | |
|
| 259 | |
protected Map<String, String> getPropertyExpressionsFromParent(String parentBeanName, |
| 260 | |
ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames) { |
| 261 | 0 | Map<String, String> propertyExpressions = new HashMap<String, String>(); |
| 262 | 0 | if (StringUtils.isBlank(parentBeanName) || !beanFactory.containsBeanDefinition(parentBeanName)) { |
| 263 | 0 | return propertyExpressions; |
| 264 | |
} |
| 265 | |
|
| 266 | 0 | if (!processedBeanNames.contains(parentBeanName)) { |
| 267 | 0 | processBeanDefinition(parentBeanName, beanFactory.getBeanDefinition(parentBeanName), beanFactory, |
| 268 | |
processedBeanNames); |
| 269 | |
} |
| 270 | |
|
| 271 | 0 | BeanDefinition beanDefinition = beanFactory.getBeanDefinition(parentBeanName); |
| 272 | 0 | MutablePropertyValues pvs = beanDefinition.getPropertyValues(); |
| 273 | |
|
| 274 | 0 | PropertyValue propertyExpressionsPV = pvs.getPropertyValue(UifPropertyPaths.PROPERTY_EXPRESSIONS); |
| 275 | 0 | if (propertyExpressionsPV != null) { |
| 276 | 0 | Object value = propertyExpressionsPV.getValue(); |
| 277 | 0 | if ((value != null) && (value instanceof ManagedMap)) { |
| 278 | 0 | propertyExpressions.putAll((ManagedMap) value); |
| 279 | |
} |
| 280 | |
} |
| 281 | |
|
| 282 | 0 | return propertyExpressions; |
| 283 | |
} |
| 284 | |
|
| 285 | |
|
| 286 | |
|
| 287 | |
|
| 288 | |
|
| 289 | |
|
| 290 | |
|
| 291 | |
|
| 292 | |
protected boolean hasExpression(Object propertyValue) { |
| 293 | 0 | if (propertyValue != null) { |
| 294 | |
|
| 295 | 0 | String strValue = getStringValue(propertyValue); |
| 296 | 0 | if (strValue != null) { |
| 297 | 0 | String elPlaceholder = StringUtils.substringBetween(strValue, UifConstants.EL_PLACEHOLDER_PREFIX, |
| 298 | |
UifConstants.EL_PLACEHOLDER_SUFFIX); |
| 299 | 0 | if (StringUtils.isNotBlank(elPlaceholder)) { |
| 300 | 0 | return true; |
| 301 | |
} |
| 302 | |
} |
| 303 | |
} |
| 304 | |
|
| 305 | 0 | return false; |
| 306 | |
} |
| 307 | |
|
| 308 | |
|
| 309 | |
|
| 310 | |
|
| 311 | |
|
| 312 | |
|
| 313 | |
|
| 314 | |
|
| 315 | |
|
| 316 | |
|
| 317 | |
|
| 318 | |
|
| 319 | |
|
| 320 | |
|
| 321 | |
protected Object processPropertyValue(String propertyName, Object propertyValue, |
| 322 | |
Map<String, String> parentPropertyExpressions, Map<String, String> propertyExpressions, |
| 323 | |
ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames) { |
| 324 | 0 | if (propertyValue == null) { |
| 325 | 0 | return null; |
| 326 | |
} |
| 327 | |
|
| 328 | |
|
| 329 | 0 | if ((propertyValue instanceof BeanDefinition) || (propertyValue instanceof BeanDefinitionHolder)) { |
| 330 | |
BeanDefinition beanDefinition; |
| 331 | 0 | if (propertyValue instanceof BeanDefinition) { |
| 332 | 0 | beanDefinition = (BeanDefinition) propertyValue; |
| 333 | |
} else { |
| 334 | 0 | beanDefinition = ((BeanDefinitionHolder) propertyValue).getBeanDefinition(); |
| 335 | |
} |
| 336 | |
|
| 337 | |
|
| 338 | 0 | removeExpressionsByPrefix(propertyName, parentPropertyExpressions); |
| 339 | 0 | processBeanDefinition(null, beanDefinition, beanFactory, processedBeanNames); |
| 340 | |
|
| 341 | 0 | return propertyValue; |
| 342 | |
} |
| 343 | |
|
| 344 | |
|
| 345 | 0 | if (propertyValue instanceof Object[]) { |
| 346 | 0 | visitArray(propertyName, parentPropertyExpressions, propertyExpressions, (Object[]) propertyValue, |
| 347 | |
beanFactory, processedBeanNames); |
| 348 | 0 | } else if (propertyValue instanceof List) { |
| 349 | 0 | visitList(propertyName, parentPropertyExpressions, propertyExpressions, (List) propertyValue, beanFactory, |
| 350 | |
processedBeanNames); |
| 351 | 0 | } else if (propertyValue instanceof Set) { |
| 352 | 0 | visitSet(propertyName, parentPropertyExpressions, propertyExpressions, (Set) propertyValue, beanFactory, |
| 353 | |
processedBeanNames); |
| 354 | 0 | } else if (propertyValue instanceof Map) { |
| 355 | 0 | visitMap(propertyName, parentPropertyExpressions, propertyExpressions, (Map) propertyValue, beanFactory, |
| 356 | |
processedBeanNames); |
| 357 | |
} |
| 358 | |
|
| 359 | |
|
| 360 | 0 | return propertyValue; |
| 361 | |
} |
| 362 | |
|
| 363 | |
|
| 364 | |
|
| 365 | |
|
| 366 | |
|
| 367 | |
|
| 368 | |
|
| 369 | |
protected void removeExpressionsByPrefix(String propertyNamePrefix, Map<String, String> propertyExpressions) { |
| 370 | 0 | Map<String, String> adjustedPropertyExpressions = new HashMap<String, String>(); |
| 371 | 0 | for (String propertyName : propertyExpressions.keySet()) { |
| 372 | 0 | if (!propertyName.startsWith(propertyNamePrefix)) { |
| 373 | 0 | adjustedPropertyExpressions.put(propertyName, propertyExpressions.get(propertyName)); |
| 374 | |
} |
| 375 | |
} |
| 376 | |
|
| 377 | 0 | propertyExpressions.clear(); |
| 378 | 0 | propertyExpressions.putAll(adjustedPropertyExpressions); |
| 379 | 0 | } |
| 380 | |
|
| 381 | |
|
| 382 | |
|
| 383 | |
|
| 384 | |
|
| 385 | |
|
| 386 | |
|
| 387 | |
protected String getStringValue(Object value) { |
| 388 | 0 | if (value instanceof TypedStringValue) { |
| 389 | 0 | TypedStringValue typedStringValue = (TypedStringValue) value; |
| 390 | 0 | return typedStringValue.getValue(); |
| 391 | 0 | } else if (value instanceof String) { |
| 392 | 0 | return (String) value; |
| 393 | |
} |
| 394 | |
|
| 395 | 0 | return null; |
| 396 | |
} |
| 397 | |
|
| 398 | |
@SuppressWarnings("unchecked") |
| 399 | |
protected void visitArray(String propertyName, Map<String, String> parentPropertyExpressions, |
| 400 | |
Map<String, String> propertyExpressions, Object[] arrayVal, ConfigurableListableBeanFactory beanFactory, |
| 401 | |
Set<String> processedBeanNames) { |
| 402 | 0 | for (int i = 0; i < arrayVal.length; i++) { |
| 403 | 0 | Object elem = arrayVal[i]; |
| 404 | 0 | String elemPropertyName = propertyName + "[" + i + "]"; |
| 405 | |
|
| 406 | 0 | if (hasExpression(elem)) { |
| 407 | 0 | String strValue = getStringValue(elem); |
| 408 | 0 | propertyExpressions.put(elemPropertyName, strValue); |
| 409 | 0 | arrayVal[i] = null; |
| 410 | 0 | } else { |
| 411 | 0 | Object newElem = processPropertyValue(elemPropertyName, elem, parentPropertyExpressions, |
| 412 | |
propertyExpressions, beanFactory, processedBeanNames); |
| 413 | 0 | arrayVal[i] = newElem; |
| 414 | |
} |
| 415 | |
|
| 416 | 0 | if (parentPropertyExpressions.containsKey(elemPropertyName)) { |
| 417 | 0 | parentPropertyExpressions.remove(elemPropertyName); |
| 418 | |
} |
| 419 | |
} |
| 420 | 0 | } |
| 421 | |
|
| 422 | |
@SuppressWarnings("unchecked") |
| 423 | |
protected void visitList(String propertyName, Map<String, String> parentPropertyExpressions, |
| 424 | |
Map<String, String> propertyExpressions, List listVal, ConfigurableListableBeanFactory beanFactory, |
| 425 | |
Set<String> processedBeanNames) { |
| 426 | 0 | List newList = new ArrayList(); |
| 427 | |
|
| 428 | 0 | for (int i = 0; i < listVal.size(); i++) { |
| 429 | 0 | Object elem = listVal.get(i); |
| 430 | 0 | String elemPropertyName = propertyName + "[" + i + "]"; |
| 431 | |
|
| 432 | 0 | if (hasExpression(elem)) { |
| 433 | 0 | String strValue = getStringValue(elem); |
| 434 | 0 | propertyExpressions.put(elemPropertyName, strValue); |
| 435 | 0 | newList.add(i, null); |
| 436 | 0 | } else { |
| 437 | 0 | Object newElem = processPropertyValue(elemPropertyName, elem, parentPropertyExpressions, |
| 438 | |
propertyExpressions, beanFactory, processedBeanNames); |
| 439 | 0 | newList.add(i, newElem); |
| 440 | |
} |
| 441 | |
|
| 442 | 0 | if (parentPropertyExpressions.containsKey(elemPropertyName)) { |
| 443 | 0 | parentPropertyExpressions.remove(elemPropertyName); |
| 444 | |
} |
| 445 | |
} |
| 446 | |
|
| 447 | |
|
| 448 | 0 | if (listVal instanceof ManagedList) { |
| 449 | 0 | boolean isMergeEnabled = ((ManagedList) listVal).isMergeEnabled(); |
| 450 | 0 | if (!isMergeEnabled) { |
| 451 | |
|
| 452 | 0 | Map<String, String> adjustedParentExpressions = new HashMap<String, String>(); |
| 453 | 0 | for (Map.Entry<String, String> parentExpression : parentPropertyExpressions.entrySet()) { |
| 454 | 0 | if (!parentExpression.getKey().startsWith(propertyName + "[")) { |
| 455 | 0 | adjustedParentExpressions.put(parentExpression.getKey(), parentExpression.getValue()); |
| 456 | |
} |
| 457 | |
} |
| 458 | |
|
| 459 | 0 | parentPropertyExpressions.clear(); |
| 460 | 0 | parentPropertyExpressions.putAll(adjustedParentExpressions); |
| 461 | |
} |
| 462 | |
} |
| 463 | |
|
| 464 | 0 | listVal.clear(); |
| 465 | 0 | listVal.addAll(newList); |
| 466 | 0 | } |
| 467 | |
|
| 468 | |
@SuppressWarnings("unchecked") |
| 469 | |
protected void visitSet(String propertyName, Map<String, String> parentPropertyExpressions, |
| 470 | |
Map<String, String> propertyExpressions, Set setVal, ConfigurableListableBeanFactory beanFactory, |
| 471 | |
Set<String> processedBeanNames) { |
| 472 | 0 | Set newContent = new LinkedHashSet(); |
| 473 | |
|
| 474 | |
|
| 475 | 0 | for (Object elem : setVal) { |
| 476 | 0 | Object newElem = processPropertyValue(propertyName, elem, parentPropertyExpressions, propertyExpressions, |
| 477 | |
beanFactory, processedBeanNames); |
| 478 | 0 | newContent.add(newElem); |
| 479 | 0 | } |
| 480 | |
|
| 481 | 0 | setVal.clear(); |
| 482 | 0 | setVal.addAll(newContent); |
| 483 | 0 | } |
| 484 | |
|
| 485 | |
@SuppressWarnings("unchecked") |
| 486 | |
protected void visitMap(String propertyName, Map<String, String> parentPropertyExpressions, |
| 487 | |
Map<String, String> propertyExpressions, Map<?, ?> mapVal, ConfigurableListableBeanFactory beanFactory, |
| 488 | |
Set<String> processedBeanNames) { |
| 489 | 0 | Map newContent = new LinkedHashMap(); |
| 490 | |
|
| 491 | 0 | boolean isMergeEnabled = false; |
| 492 | 0 | if (mapVal instanceof ManagedMap) { |
| 493 | 0 | isMergeEnabled = ((ManagedMap) mapVal).isMergeEnabled(); |
| 494 | |
} |
| 495 | |
|
| 496 | 0 | for (Map.Entry entry : mapVal.entrySet()) { |
| 497 | 0 | Object key = entry.getKey(); |
| 498 | 0 | Object val = entry.getValue(); |
| 499 | |
|
| 500 | 0 | String keyStr = getStringValue(key); |
| 501 | 0 | String elemPropertyName = propertyName + "['" + keyStr + "']"; |
| 502 | |
|
| 503 | 0 | if (hasExpression(val)) { |
| 504 | 0 | String strValue = getStringValue(val); |
| 505 | 0 | propertyExpressions.put(elemPropertyName, strValue); |
| 506 | 0 | newContent.put(key, null); |
| 507 | 0 | } else { |
| 508 | 0 | Object newElem = processPropertyValue(elemPropertyName, val, parentPropertyExpressions, |
| 509 | |
propertyExpressions, beanFactory, processedBeanNames); |
| 510 | 0 | newContent.put(key, newElem); |
| 511 | |
} |
| 512 | |
|
| 513 | 0 | if (isMergeEnabled && parentPropertyExpressions.containsKey(elemPropertyName)) { |
| 514 | 0 | parentPropertyExpressions.remove(elemPropertyName); |
| 515 | |
} |
| 516 | 0 | } |
| 517 | |
|
| 518 | 0 | if (!isMergeEnabled) { |
| 519 | |
|
| 520 | 0 | Map<String, String> adjustedParentExpressions = new HashMap<String, String>(); |
| 521 | 0 | for (Map.Entry<String, String> parentExpression : parentPropertyExpressions.entrySet()) { |
| 522 | 0 | if (!parentExpression.getKey().startsWith(propertyName + "[")) { |
| 523 | 0 | adjustedParentExpressions.put(parentExpression.getKey(), parentExpression.getValue()); |
| 524 | |
} |
| 525 | |
} |
| 526 | |
|
| 527 | 0 | parentPropertyExpressions.clear(); |
| 528 | 0 | parentPropertyExpressions.putAll(adjustedParentExpressions); |
| 529 | |
} |
| 530 | |
|
| 531 | 0 | mapVal.clear(); |
| 532 | 0 | mapVal.putAll(newContent); |
| 533 | 0 | } |
| 534 | |
} |