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.config.spring.parsers.assembly.BeanAssembler; |
16 | |
import org.mule.object.AbstractObjectFactory; |
17 | |
|
18 | |
import org.springframework.beans.factory.config.BeanDefinition; |
19 | |
import org.springframework.beans.factory.xml.ParserContext; |
20 | |
import org.w3c.dom.Element; |
21 | |
|
22 | |
public class ObjectFactoryDefinitionParser extends AbstractChildDefinitionParser |
23 | |
{ |
24 | |
|
25 | 0 | protected Class beanClass = null; |
26 | 0 | protected String setterMethod = null; |
27 | |
|
28 | |
public ObjectFactoryDefinitionParser(Class beanClass, String setterMethod) |
29 | |
{ |
30 | 0 | this(beanClass); |
31 | 0 | this.setterMethod = setterMethod; |
32 | 0 | } |
33 | |
|
34 | |
public ObjectFactoryDefinitionParser(Class beanClass) |
35 | |
{ |
36 | 0 | super(); |
37 | 0 | this.beanClass = beanClass; |
38 | 0 | setAllowClassAttribute(false); |
39 | 0 | addAlias(AbstractMuleBeanDefinitionParser.ATTRIBUTE_CLASS, AbstractObjectFactory.ATTRIBUTE_OBJECT_CLASS_NAME); |
40 | 0 | addAlias(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF, "factoryBean"); |
41 | 0 | } |
42 | |
|
43 | |
public String getPropertyName(Element element) |
44 | |
{ |
45 | 0 | if (setterMethod != null) |
46 | |
{ |
47 | 0 | return setterMethod; |
48 | |
} |
49 | |
else |
50 | |
{ |
51 | 0 | BeanDefinition parent = getParentBeanDefinition(element); |
52 | 0 | String setter = (String) parent.getAttribute(ObjectFactoryWrapper.OBJECT_FACTORY_SETTER); |
53 | 0 | return setter; |
54 | |
} |
55 | |
} |
56 | |
|
57 | |
protected Class getBeanClass(Element element) |
58 | |
{ |
59 | 0 | return beanClass; |
60 | |
} |
61 | |
} |