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 {
30 this.muleContext = muleContext;
31 }
32
33 public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
34 {
35 if (bean instanceof MuleContextAware)
36 {
37 if (muleContext == null)
38 {
39 return bean;
40 }
41
42 ((MuleContextAware) bean).setMuleContext(muleContext);
43 }
44 return bean;
45 }
46
47 public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
48 {
49 return bean;
50 }
51
52 }