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.services;
8   
9   import org.mule.RequestContext;
10  import org.mule.util.StringMessageUtils;
11  
12  import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
13  import org.apache.commons.logging.Log;
14  import org.apache.commons.logging.LogFactory;
15  
16  public class TestReceiver
17  {
18      protected static final Log logger = LogFactory.getLog(TestComponent.class);
19  
20      protected AtomicInteger count = new AtomicInteger(0);
21  
22      public String receive(String message) throws Exception
23      {
24          if (logger.isDebugEnabled())
25          {
26              logger.debug(StringMessageUtils.getBoilerPlate("Received: " + message + " Number: " + inc()
27                                                             + " in thread: "
28                                                             + Thread.currentThread().getName()));
29              logger.debug("Message ID is: " + RequestContext.getEventContext().getMessage().getCorrelationId());
30          }
31  
32          return "Received: " + message;
33      }
34  
35      protected int inc()
36      {
37          return count.incrementAndGet();
38      }
39  
40  }