1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.config.spring.parsers.assembly; |
12 | |
|
13 | |
import org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration; |
14 | |
import org.mule.util.MapCombiner; |
15 | |
|
16 | |
import java.util.Iterator; |
17 | |
import java.util.List; |
18 | |
import java.util.Map; |
19 | |
|
20 | |
import org.springframework.beans.PropertyValue; |
21 | |
import org.springframework.beans.factory.config.BeanDefinition; |
22 | |
import org.springframework.beans.factory.support.BeanDefinitionBuilder; |
23 | |
import org.springframework.beans.factory.support.ManagedList; |
24 | |
import org.springframework.beans.factory.support.ManagedMap; |
25 | |
|
26 | |
public abstract class AbstractMapBeanAssembler extends DefaultBeanAssembler |
27 | |
{ |
28 | |
|
29 | |
public AbstractMapBeanAssembler(PropertyConfiguration beanConfig, BeanDefinitionBuilder bean, |
30 | |
PropertyConfiguration targetConfig, BeanDefinition target) |
31 | |
{ |
32 | 0 | super(beanConfig, bean, targetConfig, target); |
33 | 0 | } |
34 | |
|
35 | |
protected void insertDefinitionAsMap(String oldName) |
36 | |
{ |
37 | 0 | BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(MapCombiner.class); |
38 | 0 | Map map = new ManagedMap(); |
39 | 0 | for (Iterator pvs = getBean().getBeanDefinition().getPropertyValues().getPropertyValueList().iterator(); |
40 | 0 | pvs.hasNext();) |
41 | |
{ |
42 | 0 | PropertyValue pv = (PropertyValue) pvs.next(); |
43 | 0 | map.put(pv.getName(), pv.getValue()); |
44 | 0 | } |
45 | 0 | List list = new ManagedList(); |
46 | 0 | list.add(map); |
47 | 0 | builder.addPropertyValue(MapCombiner.LIST, list); |
48 | 0 | setBean(builder); |
49 | 0 | super.insertBeanInTarget(oldName); |
50 | 0 | } |
51 | |
|
52 | |
} |