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 | 0 | public class MuleObjectNameProcessor implements BeanPostProcessor |
32 | |
{ |
33 | 0 | private boolean overwrite = false; |
34 | |
|
35 | |
public Object postProcessBeforeInitialization(Object o, String s) throws BeansException |
36 | |
{ |
37 | 0 | if (!MuleObjectHelper.class.getName().equals(s)) |
38 | |
{ |
39 | 0 | if (o instanceof UMOConnector) |
40 | |
{ |
41 | 0 | if (((UMOConnector)o).getName() == null || overwrite) |
42 | |
{ |
43 | 0 | ((UMOConnector)o).setName(s); |
44 | |
} |
45 | |
} |
46 | 0 | else if (o instanceof UMOTransformer) |
47 | |
{ |
48 | 0 | ((UMOTransformer)o).setName(s); |
49 | |
} |
50 | 0 | else if (o instanceof UMOEndpoint) |
51 | |
{ |
52 | |
|
53 | |
|
54 | 0 | if ((((UMOEndpoint)o).getName() == null || overwrite) |
55 | |
&& s.indexOf(MuleEndpoint.class.getName()) == -1) |
56 | |
{ |
57 | 0 | ((UMOEndpoint)o).setName(s); |
58 | |
} |
59 | |
} |
60 | 0 | else if (o instanceof UMODescriptor) |
61 | |
{ |
62 | 0 | if (((UMODescriptor)o).getName() == null || overwrite) |
63 | |
{ |
64 | 0 | ((UMODescriptor)o).setName(s); |
65 | |
} |
66 | |
} |
67 | 0 | else if (o instanceof UMOModel) |
68 | |
{ |
69 | 0 | if (((UMOModel)o).getName() == null || overwrite) |
70 | |
{ |
71 | 0 | ((UMOModel)o).setName(s); |
72 | |
} |
73 | |
} |
74 | 0 | else if (o instanceof UMOAgent) |
75 | |
{ |
76 | 0 | ((UMOAgent)o).setName(s); |
77 | |
} |
78 | |
} |
79 | 0 | return o; |
80 | |
} |
81 | |
|
82 | |
public Object postProcessAfterInitialization(Object o, String s) throws BeansException |
83 | |
{ |
84 | 0 | return o; |
85 | |
} |
86 | |
|
87 | |
public boolean isOverwrite() |
88 | |
{ |
89 | 0 | return overwrite; |
90 | |
} |
91 | |
|
92 | |
public void setOverwrite(boolean overwrite) |
93 | |
{ |
94 | 0 | this.overwrite = overwrite; |
95 | 0 | } |
96 | |
|
97 | |
} |