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