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.context.MuleContextAware;
15
16 import org.springframework.beans.BeansException;
17 import org.springframework.beans.factory.config.BeanPostProcessor;
18
19
20
21
22
23
24
25
26
27 public class MuleContextPostProcessor implements BeanPostProcessor
28 {
29
30 private MuleContext muleContext;
31
32 public MuleContextPostProcessor(MuleContext muleContext)
33 {
34 this.muleContext = muleContext;
35 }
36
37 public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
38 {
39 if (bean instanceof MuleContextAware)
40 {
41 if (muleContext == null)
42 {
43 return bean;
44 }
45
46 ((MuleContextAware) bean).setMuleContext(muleContext);
47 }
48 return bean;
49 }
50
51 public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
52 {
53 return bean;
54 }
55
56 }