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