01: /*
02: * $Id: LoggingCatchAllStrategy.java 10961 2008-02-22 19:01:02Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
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: private static final Log logger = LogFactory
30: .getLog(DefaultMuleEvent.class);
31:
32: public void setEndpoint(OutboundEndpoint endpoint) {
33: throw new UnsupportedOperationException(
34: "An endpoint cannot be set on this Catch All strategy");
35: }
36:
37: public void setEndpoint(String endpoint) {
38: throw new UnsupportedOperationException(
39: "An endpoint cannot be set on this Catch All strategy");
40: }
41:
42: public OutboundEndpoint getEndpoint() {
43: return null;
44: }
45:
46: public MuleMessage catchMessage(MuleMessage message,
47: MuleSession session, boolean synchronous)
48: throws RoutingException {
49: logger.warn("Message: " + message
50: + " was not dispatched on session: " + session
51: + ". No routing path was defined for it.");
52: return null;
53: }
54: }
|