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.tck;
8   
9   import org.mule.api.MuleEvent;
10  import org.mule.api.MuleException;
11  import org.mule.api.processor.MessageProcessor;
12  import org.mule.api.source.MessageSource;
13  import org.mule.util.ObjectUtils;
14  
15  public class TriggerableMessageSource implements MessageSource
16  {
17      protected MessageProcessor listener;
18  
19      public TriggerableMessageSource()
20      {
21          // empty
22      }
23  
24      public TriggerableMessageSource(MessageProcessor listener)
25      {
26          this.listener = listener;
27      }
28  
29      public MuleEvent trigger(MuleEvent event) throws MuleException
30      {
31          return listener.process(event);
32      }
33  
34      public void setListener(MessageProcessor listener)
35      {
36          this.listener = listener;
37      }
38      
39      @Override
40      public String toString()
41      {
42          return ObjectUtils.toString(this);
43      }
44  }