1
2
3
4
5
6
7
8
9
10
11 package org.mule.extras.spring.config;
12
13 import org.mule.impl.endpoint.MuleEndpoint;
14 import org.mule.umo.UMODescriptor;
15 import org.mule.umo.endpoint.UMOEndpoint;
16 import org.mule.umo.manager.UMOAgent;
17 import org.mule.umo.model.UMOModel;
18 import org.mule.umo.provider.UMOConnector;
19 import org.mule.umo.transformer.UMOTransformer;
20 import org.mule.util.MuleObjectHelper;
21
22 import org.springframework.beans.BeansException;
23 import org.springframework.beans.factory.config.BeanPostProcessor;
24
25
26
27
28
29
30
31 public class MuleObjectNameProcessor implements BeanPostProcessor
32 {
33 private boolean overwrite = false;
34
35 public Object postProcessBeforeInitialization(Object o, String s) throws BeansException
36 {
37 if (!MuleObjectHelper.class.getName().equals(s))
38 {
39 if (o instanceof UMOConnector)
40 {
41 if (((UMOConnector)o).getName() == null || overwrite)
42 {
43 ((UMOConnector)o).setName(s);
44 }
45 }
46 else if (o instanceof UMOTransformer)
47 {
48 ((UMOTransformer)o).setName(s);
49 }
50 else if (o instanceof UMOEndpoint)
51 {
52
53
54 if ((((UMOEndpoint)o).getName() == null || overwrite)
55 && s.indexOf(MuleEndpoint.class.getName()) == -1)
56 {
57 ((UMOEndpoint)o).setName(s);
58 }
59 }
60 else if (o instanceof UMODescriptor)
61 {
62 if (((UMODescriptor)o).getName() == null || overwrite)
63 {
64 ((UMODescriptor)o).setName(s);
65 }
66 }
67 else if (o instanceof UMOModel)
68 {
69 if (((UMOModel)o).getName() == null || overwrite)
70 {
71 ((UMOModel)o).setName(s);
72 }
73 }
74 else if (o instanceof UMOAgent)
75 {
76 ((UMOAgent)o).setName(s);
77 }
78 }
79 return o;
80 }
81
82 public Object postProcessAfterInitialization(Object o, String s) throws BeansException
83 {
84 return o;
85 }
86
87 public boolean isOverwrite()
88 {
89 return overwrite;
90 }
91
92 public void setOverwrite(boolean overwrite)
93 {
94 this.overwrite = overwrite;
95 }
96
97 }