View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.spring.events;
8   
9   import org.mule.tck.functional.EventCallback;
10  
11  import org.apache.commons.logging.Log;
12  import org.apache.commons.logging.LogFactory;
13  import org.springframework.context.ApplicationEvent;
14  import org.springframework.context.ApplicationListener;
15  
16  /**
17   * <code>TestMuleEventBean</code> is a MuleEventBean for testing with the
18   * MuleEventMulticaster.
19   */
20  
21  public class TestAllEventBean implements MuleEventListener, ApplicationListener
22  {
23      private final Log logger = LogFactory.getLog(this.getClass());
24      private EventCallback eventCallback;
25  
26      public void onApplicationEvent(ApplicationEvent event)
27      {
28          logger.debug("Received message: " + event);
29  
30          if (eventCallback != null)
31          {
32              try
33              {
34                  eventCallback.eventReceived(null, event);
35              }
36              catch (Exception e1)
37              {
38                  throw new RuntimeException("Callback failed: " + e1.getMessage(), e1);
39              }
40          }
41      }
42  
43      public EventCallback getEventCallback()
44      {
45          return eventCallback;
46      }
47  
48      public void setEventCallback(EventCallback eventCallback)
49      {
50          this.eventCallback = eventCallback;
51      }
52  
53  }