View Javadoc

1   /*
2    * $Id: LoggingCatchAllStrategy.java 10961 2008-02-22 19:01:02Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.routing;
12  
13  import org.mule.DefaultMuleEvent;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.MuleSession;
16  import org.mule.api.endpoint.OutboundEndpoint;
17  import org.mule.api.routing.RoutingException;
18  
19  import org.apache.commons.logging.Log;
20  import org.apache.commons.logging.LogFactory;
21  
22  /**
23   * <code>LoggingCatchAllStrategy</code> is a simple strategy that only logs any
24   * events not caught by the router associated with this strategy. This should <b>not</b>
25   * be used in production unless it is acceptible for events to be disposing.
26   */
27  
28  public class LoggingCatchAllStrategy extends AbstractCatchAllStrategy
29  {
30      private static final Log logger = LogFactory.getLog(DefaultMuleEvent.class);
31  
32      public void setEndpoint(OutboundEndpoint endpoint)
33      {
34          throw new UnsupportedOperationException("An endpoint cannot be set on this Catch All strategy");
35      }
36  
37      public void setEndpoint(String endpoint)
38      {
39          throw new UnsupportedOperationException("An endpoint cannot be set on this Catch All strategy");
40      }
41  
42      public OutboundEndpoint getEndpoint()
43      {
44          return null;
45      }
46  
47      public MuleMessage catchMessage(MuleMessage message, MuleSession session, boolean synchronous)
48          throws RoutingException
49      {
50          logger.warn("Message: " + message + " was not dispatched on session: " + session
51                      + ". No routing path was defined for it.");
52          return null;
53      }
54  }