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.notification.ServerNotificationListener;
11 import org.springframework.beans.BeansException;
12 import org.springframework.beans.factory.config.BeanPostProcessor;
13
14
15
16
17
18
19
20
21
22 public class NotificationListenersPostProcessor implements BeanPostProcessor
23 {
24
25 private final MuleContext muleContext;
26
27 public NotificationListenersPostProcessor(MuleContext muleContext)
28 {
29 this.muleContext = muleContext;
30 }
31
32 public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
33 {
34 if (bean instanceof ServerNotificationListener)
35 {
36 if (!muleContext.getNotificationManager().isListenerRegistered((ServerNotificationListener) bean))
37 {
38 muleContext.getNotificationManager().addListener((ServerNotificationListener) bean);
39 }
40 }
41 return bean;
42 }
43
44 public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
45 {
46 return bean;
47 }
48
49 }