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