Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/mule/umo/impl/DefaultExceptionStrategy.java


1   /* 
2    * $Header: /cvsroot/mule/mule/src/java/org/mule/umo/impl/DefaultExceptionStrategy.java,v 1.6 2003/10/20 21:44:38 rossmason Exp $
3    * $Revision: 1.6 $
4    * $Date: 2003/10/20 21:44:38 $
5    * ------------------------------------------------------------------------------------------------------
6    * 
7    * Copyright (c) Cubis Limited. All rights reserved.
8    * http://www.cubis.co.uk 
9    * 
10   * The software in this package is published under the terms of the BSD
11   * style license a copy of which has been included with this distribution in
12   * the LICENSE.txt file. 
13   *
14   */
15  package org.mule.umo.impl;
16  
17  import org.apache.commons.logging.Log;
18  import org.apache.commons.logging.LogFactory;
19  import org.mule.umo.UMOExceptionStrategy;
20  import org.mule.umo.UniversalMessageObject;
21  
22  /**
23   *  <p><code>DefaultExceptionStrategy</code> Provides a default exception handling strategy.  The class final thus to
24   * change exception handling behaviour the user must reimplemented the ExceptionListener Interface
25   *
26   * @author Ross Mason
27   * @version $Revision: 1.6 $
28   */
29  
30  public class DefaultExceptionStrategy implements UMOExceptionStrategy
31  {
32      /** logger used by this class */
33      private static transient Log log = LogFactory.getLog(DefaultExceptionStrategy.class);
34  
35      /** The parent to which the Exception handler belongs */
36      private UniversalMessageObject parent;
37  
38      /**
39       * Default Constructor
40       */
41      public DefaultExceptionStrategy()
42      {
43      }
44  
45      /**
46       * Constructor
47       * @param parent the owner of this exception strategy
48       * @see UniversalMessageObject
49       */
50      public DefaultExceptionStrategy(UniversalMessageObject parent)
51      {
52          setParent(parent);
53      }
54  
55      /* (non-Javadoc)
56       * @see org.mule.umo.UMOExceptionStrategy#handleException(java.lang.Object, java.lang.Throwable)
57       */
58      public Throwable handleException(Object message, Throwable t)
59      {
60          log.error("Caught exception: " + t, t);
61          if (message instanceof String && !((String) message).startsWith("<"))
62          {
63              log.error("Erorr Message was: " + message.toString());
64          }
65          log.error("Message being processed is: " + message.toString());
66          return t;
67      }
68  
69      /* (non-Javadoc)
70       * @see org.mule.umo.UMOExceptionStrategy#setParent(org.mule.umo.UniversalMessageObject)
71       */
72      public void setParent(UniversalMessageObject parent)
73      {
74          this.parent = parent;
75      }
76  
77      /* (non-Javadoc)
78       * @see org.mule.umo.UMOExceptionStrategy#getParent()
79       */
80      public UniversalMessageObject getParent()
81      {
82          return parent;
83      }
84  }