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