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.testmodels.mule;
8   
9   import org.mule.api.MuleEvent;
10  import org.mule.api.MuleException;
11  import org.mule.api.NamedObject;
12  import org.mule.api.processor.MessageProcessor;
13  import org.mule.util.ObjectUtils;
14  
15  public class TestMessageProcessor implements MessageProcessor, NamedObject
16  {
17      /** Simple label string to be appended to the payload. */
18      private String label;
19      
20      /** Bean name used by Spring */
21      private String name;
22      
23      public TestMessageProcessor()
24      {
25          // For IoC
26      }
27      
28      public TestMessageProcessor(String label)
29      {
30          this.label = label;
31      }
32      
33      public MuleEvent process(MuleEvent event) throws MuleException
34      {
35          if (event != null && event.getMessage() != null)
36          {
37              event.getMessage().setPayload(event.getMessage().getPayload() + ":" + label);
38          }
39          return event;
40      }
41  
42      public String getLabel()
43      {
44          return label;
45      }
46  
47      public void setLabel(String label)
48      {
49          this.label = label;
50      }
51  
52      public void setName(String name)
53      {
54          this.name = name;
55      }
56  
57      public String getName()
58      {
59          return name;
60      }
61  
62      @Override
63      public String toString()
64      {
65          return ObjectUtils.toString(this);
66      }
67  }
68  
69