View Javadoc

1   /*
2    * $Id: LoggingCatchAllStrategy.java 7963 2007-08-21 08:53:15Z dirk.olmes $
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.impl.MuleEvent;
14  import org.mule.umo.UMOMessage;
15  import org.mule.umo.UMOSession;
16  import org.mule.umo.endpoint.UMOEndpoint;
17  import org.mule.umo.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(MuleEvent.class);
31  
32      public void setEndpoint(UMOEndpoint 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 UMOEndpoint getEndpoint()
43      {
44          return null;
45      }
46  
47      public UMOMessage catchMessage(UMOMessage message, UMOSession 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  }