View Javadoc

1   /*
2    * $Id: ServiceLoggingMessageProcessor.java 22439 2011-07-18 19:06:39Z dfeist $
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.service.processor;
12  
13  import org.mule.api.MuleEvent;
14  import org.mule.api.MuleException;
15  import org.mule.api.processor.MessageProcessor;
16  import org.mule.api.service.Service;
17  
18  import org.apache.commons.logging.Log;
19  import org.apache.commons.logging.LogFactory;
20  
21  public class ServiceLoggingMessageProcessor implements MessageProcessor
22  {
23      protected final transient Log logger = LogFactory.getLog(getClass());
24      protected Service service;
25  
26      public ServiceLoggingMessageProcessor(Service service)
27      {
28          this.service = service;
29      }
30  
31      public MuleEvent process(MuleEvent event) throws MuleException
32      {
33          if (event.getExchangePattern().hasResponse())
34          {
35              if (logger.isDebugEnabled())
36              {
37                  logger.debug("Service: " + service.getName() + " has received synchronous event on: "
38                               + event.getMessageSourceURI());
39              }
40          }
41          else
42          {
43              if (logger.isDebugEnabled())
44              {
45                  logger.debug("Service: " + service.getName() + " has received asynchronous event on: "
46                               + event.getMessageSourceURI());
47              }
48          }
49  
50          return event;
51      }
52  }