View Javadoc

1   /*
2    * $Id: TestMessageProcessor.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.tck.testmodels.mule;
12  
13  import org.mule.api.MuleEvent;
14  import org.mule.api.MuleException;
15  import org.mule.api.NamedObject;
16  import org.mule.api.processor.MessageProcessor;
17  import org.mule.util.ObjectUtils;
18  
19  public class TestMessageProcessor implements MessageProcessor, NamedObject
20  {
21      /** Simple label string to be appended to the payload. */
22      private String label;
23      
24      /** Bean name used by Spring */
25      private String name;
26      
27      public TestMessageProcessor()
28      {
29          // For IoC
30      }
31      
32      public TestMessageProcessor(String label)
33      {
34          this.label = label;
35      }
36      
37      public MuleEvent process(MuleEvent event) throws MuleException
38      {
39          if (event != null && event.getMessage() != null)
40          {
41              event.getMessage().setPayload(event.getMessage().getPayload() + ":" + label);
42          }
43          return event;
44      }
45  
46      public String getLabel()
47      {
48          return label;
49      }
50  
51      public void setLabel(String label)
52      {
53          this.label = label;
54      }
55  
56      public void setName(String name)
57      {
58          this.name = name;
59      }
60  
61      public String getName()
62      {
63          return name;
64      }
65  
66      @Override
67      public String toString()
68      {
69          return ObjectUtils.toString(this);
70      }
71  }
72  
73