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