1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.config.spring.parsers.specific; |
12 | |
|
13 | |
import org.mule.config.spring.parsers.AbstractChildDefinitionParser; |
14 | |
import org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser; |
15 | |
import org.mule.object.AbstractObjectFactory; |
16 | |
|
17 | |
import org.springframework.beans.factory.config.BeanDefinition; |
18 | |
import org.w3c.dom.Element; |
19 | |
|
20 | |
public class ObjectFactoryDefinitionParser extends AbstractChildDefinitionParser |
21 | |
{ |
22 | |
|
23 | 0 | protected Class beanClass = null; |
24 | 0 | protected String setterMethod = null; |
25 | |
|
26 | |
public ObjectFactoryDefinitionParser(Class beanClass, String setterMethod) |
27 | |
{ |
28 | 0 | this(beanClass); |
29 | 0 | this.setterMethod = setterMethod; |
30 | 0 | } |
31 | |
|
32 | |
public ObjectFactoryDefinitionParser(Class beanClass) |
33 | |
{ |
34 | 0 | super(); |
35 | 0 | this.beanClass = beanClass; |
36 | 0 | setAllowClassAttribute(false); |
37 | 0 | addAlias(AbstractMuleBeanDefinitionParser.ATTRIBUTE_CLASS, AbstractObjectFactory.ATTRIBUTE_OBJECT_CLASS_NAME); |
38 | 0 | addAlias(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF, "factoryBean"); |
39 | 0 | } |
40 | |
|
41 | |
public String getPropertyName(Element element) |
42 | |
{ |
43 | 0 | if (setterMethod != null) |
44 | |
{ |
45 | 0 | return setterMethod; |
46 | |
} |
47 | |
else |
48 | |
{ |
49 | 0 | BeanDefinition parent = getParentBeanDefinition(element); |
50 | 0 | String setter = (String) parent.getAttribute(ObjectFactoryWrapper.OBJECT_FACTORY_SETTER); |
51 | 0 | return setter; |
52 | |
} |
53 | |
} |
54 | |
|
55 | |
protected Class getBeanClass(Element element) |
56 | |
{ |
57 | 0 | return beanClass; |
58 | |
} |
59 | |
} |