View Javadoc

1   /*
2    * $Id$
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.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.util.ObjectUtils;
17  
18  import org.apache.commons.logging.Log;
19  import org.apache.commons.logging.LogFactory;
20  
21  /**
22   * Can be used for simple {@link MessageProcessor}s that require the
23   * {@link MuleEvent} to log or send notifications etc. but don't modify it in any way
24   * or pass it on to another message processor.
25   */
26  public abstract class AbstractMessageObserver implements MessageProcessor
27  {
28  
29      protected Log logger = LogFactory.getLog(getClass());
30  
31      public final MuleEvent process(MuleEvent event) throws MuleException
32      {
33          // TODO Make event/message immutable before invoking observe
34          observe(event);
35          return event;
36      }
37  
38      public abstract void observe(MuleEvent event);
39      
40      @Override
41      public String toString()
42      {
43          return ObjectUtils.toString(this);
44      }
45  }