View Javadoc

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