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