View Javadoc

1   /*
2    * $Id: ExceptionHolder.java 10489 2008-01-23 17:53:38Z 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  package org.mule.util;
11  
12  import java.beans.ExceptionListener;
13  import java.util.ArrayList;
14  import java.util.Iterator;
15  import java.util.List;
16  
17  /** TODO */
18  public class ExceptionHolder implements ExceptionListener
19  {
20      private List exceptions = new ArrayList(2);
21  
22      public void exceptionThrown(Exception e)
23      {
24          exceptions.add(e);
25      }
26  
27      public List getExceptions()
28      {
29          return exceptions;
30      }
31  
32      public boolean isExceptionThrown()
33      {
34          return exceptions.size() > 0;
35      }
36  
37      public void clear()
38      {
39          exceptions.clear();
40      }
41  
42      public void print()
43      {
44          for (Iterator iterator = exceptions.iterator(); iterator.hasNext();)
45          {
46              Exception exception = (Exception) iterator.next();
47              exception.printStackTrace();
48          }
49      }
50  }