1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.config.spring; |
12 | |
|
13 | |
import org.mule.api.MuleContext; |
14 | |
import org.mule.api.expression.ExpressionEvaluator; |
15 | |
import org.mule.api.expression.ExpressionManager; |
16 | |
|
17 | |
import org.springframework.beans.BeansException; |
18 | |
import org.springframework.beans.factory.config.BeanPostProcessor; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
public class ExpressionEvaluatorPostProcessor implements BeanPostProcessor |
26 | |
{ |
27 | |
private MuleContext muleContext; |
28 | |
|
29 | |
public ExpressionEvaluatorPostProcessor(MuleContext muleContext) |
30 | 0 | { |
31 | 0 | this.muleContext = muleContext; |
32 | 0 | } |
33 | |
|
34 | |
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException |
35 | |
{ |
36 | 0 | if (muleContext == null) |
37 | |
{ |
38 | 0 | return bean; |
39 | |
} |
40 | |
|
41 | 0 | if (bean instanceof ExpressionEvaluator) |
42 | |
{ |
43 | 0 | ExpressionEvaluator ee = (ExpressionEvaluator) bean; |
44 | |
|
45 | 0 | final ExpressionManager expressionManager = muleContext.getExpressionManager(); |
46 | 0 | if (!expressionManager.isEvaluatorRegistered(ee.getName())) |
47 | |
{ |
48 | 0 | expressionManager.registerEvaluator(ee); |
49 | |
} |
50 | |
} |
51 | 0 | return bean; |
52 | |
} |
53 | |
|
54 | |
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException |
55 | |
{ |
56 | 0 | return bean; |
57 | |
} |
58 | |
|
59 | |
} |