1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.spring.events;
12
13 import org.mule.module.spring.events.MuleApplicationEvent;
14 import org.mule.module.spring.events.MuleEventListener;
15 import org.mule.tck.functional.EventCallback;
16 import org.mule.util.StringMessageUtils;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20 import org.springframework.context.ApplicationEvent;
21
22
23
24
25
26
27 public class TestMuleEventBean implements MuleEventListener
28 {
29 private static final Log logger = LogFactory.getLog(TestMuleEventBean.class);
30
31 private EventCallback eventCallback;
32
33 public void onApplicationEvent(ApplicationEvent event)
34 {
35 MuleApplicationEvent e = (MuleApplicationEvent)event;
36
37 logger.debug(StringMessageUtils.getBoilerPlate("Received message on " + e.getEndpoint()));
38
39 if (eventCallback != null)
40 {
41 try
42 {
43 eventCallback.eventReceived(e.getMuleEventContext(), event);
44 }
45 catch (Exception e1)
46 {
47 throw new RuntimeException("Callback failed: " + e1.getMessage(), e1);
48 }
49 }
50 }
51
52 public EventCallback getEventCallback()
53 {
54 return eventCallback;
55 }
56
57 public void setEventCallback(EventCallback eventCallback)
58 {
59 this.eventCallback = eventCallback;
60 }
61
62 }